foreach bound to observableArray in a jQuery UI dialog fails to notice update #519

andygjp opened this Issue Jun 8, 2012 · 3 comments


None yet
3 participants

andygjp commented Jun 8, 2012

I don't think it is possible to use a foreach bound to an observableArray in a jQuery UI dialog that is bound to the viewmodel - other bindings, e.g. text, that are bound to observable seem to work fine.

This broken sample uses a dialog bound to the viewmodel which I based on a sample found here (I think).

This sample accomplishes what I want. The dialog, however, is not bound to the viewmodel, instead I wire up a click handler to a button to launch the dialog (taken from this article).

Is this a bug, or am I doing it wrong?

This is a MVC3 project, using jQuery-1.7.2, jQuery-ui-1.8.20.js and knockout-2.1.0.

(This is taken from my SO question)


rniemeyer commented Jun 8, 2012

@andygjp Here is your broken sample with a minor modification to call the .dialog() in a setTimeout: The jQuery UI dialog functionality moves the element to the bottom of the page, so it can mess up the bindings as the initial pass of ko.applyBindings hits it for a second time.

Here is another sample that calls ko.applyBindings specific to a container element (without the setTimeout): This means that ko.applyBindings won't hit the moved dialog the second time, as it will be outside of the container element.

Sorry, I don't have time to add any more details. Hope this helps.


mbest commented Jun 9, 2012

#466 presents some ideas on preventing Knockout from trying to bind an element twice. Closing this as it's the same issue.

mbest closed this Jun 9, 2012

andygjp commented Jun 9, 2012

Thanks for that, I've marked your response as the answer.

I'll just close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment