Giter VIP home page Giter VIP logo

Comments (9)

thvd avatar thvd commented on June 18, 2024

I think it shouldn't be an computed observable, but a normal anonymous function.

from knockout.mapping.

greenlaw110 avatar greenlaw110 commented on June 18, 2024

No I need it to be computed, because I want the ajax loading be run each time I changed the current client

from knockout.mapping.

thvd avatar thvd commented on June 18, 2024

Then you need to subscribe on the current client. http://knockoutjs.com/documentation/observables.html#explicitly_subscribing_to_observables
Because the $.ajax method is asynchronous.

from knockout.mapping.

greenlaw110 avatar greenlaw110 commented on June 18, 2024

Yes, inside the function I have var client = data.curClient();, that statement makes the computed function get called everytime the curClient changes

from knockout.mapping.

thvd avatar thvd commented on June 18, 2024

No, you should subscribe, as mentioned on the page i linked for you, on the data.curClient like this:


data.curClient.subscribe(function(newValue) {
    // this function will every time executed when data.curClient changes.
    // put here your ajax request, like the code you had in your first message in the ko.computed block.

});


from knockout.mapping.

greenlaw110 avatar greenlaw110 commented on June 18, 2024

I read that. What's difference between it and invoking the observable in a ko.computed ? I was always using ko.computed without any problem until I met this issue

from knockout.mapping.

thvd avatar thvd commented on June 18, 2024

We are actually talking about the way how to implement. But maybe it's a good idea to create a fiddle? So we can dig into your actually problem (an infinite loop) a bit better.

from knockout.mapping.

sagacity avatar sagacity commented on June 18, 2024

No reply for over a month. Please feel free to reopen this issue!

from knockout.mapping.

hanxuema avatar hanxuema commented on June 18, 2024

hi greenlaw110

Did you find the reason why this issues was happening and what you did to solve the issue? Can you please share?

Regards

from knockout.mapping.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.