Giter Site home page Giter Site logo

Comments (3)

clekkas avatar clekkas commented on June 24, 2024

Hi DrSammyD,

Can you provide a more complete example for me to work with, you can use either http://jsfiddle.net or http://plnkr.co to share your code.

One thing I did notice is that your computed is missing the second parameter, 'this'. Here is an explanation of what the second parameter is; from knockoutjs.com (http://knockoutjs.com/documentation/computedObservables.html)

"...This defines the value of this when evaluating the computed observable. Without passing it in, it would not have been possible to refer to this.firstName() or this.lastName()...."

So I would expect in your code something like this:

  self.rigSelect = ko.dependentObservable(function () {
            var rigs = _(self.rigs()).map(function (rig) {
                return {
                    rig: rig,
                    name: '('+(rig.number())+ ') ' + (rig.name())
                };
            });
            return rigs.value();

        }, this);

Hope this helps

from knockout-deferred-updates.

mbest avatar mbest commented on June 24, 2024

@DrSammyD, what version of Deferred Updates? Can you provide a complete stack trace?

from knockout-deferred-updates.

DrSammyD avatar DrSammyD commented on June 24, 2024

Sorry guys, I'm having difficulty replicating this error. I went into the code and fixed it locally, then continued coding the rest of my view model, didn't check anything in because it was erring out.

I'm using version 3.0.0
I changed line 534 to

if ((!dependentObservable.equalityComparer || !dependentObservable.equalityComparer(_latestValue, newValue)) /*&& dependentObservable.notifySubscribers != undefined*/) 

which fixed the problem, but I'm not sure what else that might do to the code.
My model looked like this

var vm = function () {
    var self = this;
    self.rigs = ko.observableArray();
    self.rigs(service.getRigs());
    self.rigSelect = ko.dependentObservable(function () {
        var rigs = _(self.rigs()).map(function (rig) {
            return {
                rig: rig,
                name: '('+(rig.number())+ ') ' + (rig.name())
            };
        });
        return rigs.value();
   });

};

When I took out my fix to get the stack trace, the error didn't come back. I'll let you know if/when it does.

from knockout-deferred-updates.

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.