Note that there are some explanatory texts on larger screens.

plurals
  1. POError with latest knockout and jquery ui dialog: cannot call prior to initialization
    text
    copied!<p>I try to use with knockout 2.2 custom binding new jquery 1.9 and jquery ui 1.9.2. Code is from here: <a href="https://stackoverflow.com/questions/8611327/integrating-jquery-ui-dialog-with-knockoutjs">integrating jquery ui dialog with knockoutjs</a> With updated libraries: <a href="http://jsfiddle.net/SnPdE/323/" rel="nofollow noreferrer">http://jsfiddle.net/SnPdE/323/</a></p> <pre><code>ko.bindingHandlers.dialog = { init: function(element, valueAccessor, allBindingsAccessor) { var options = ko.utils.unwrapObservable(valueAccessor()) || {}; //do in a setTimeout, so the applyBindings doesn't bind twice from element being copied and moved to bottom setTimeout(function() { options.close = function() { allBindingsAccessor().dialogVisible(false); }; $(element).dialog(options); }, 0); //handle disposal (not strictly necessary in this scenario) ko.utils.domNodeDisposal.addDisposeCallback(element, function() { $(element).dialog("destroy"); }); }, update: function(element, valueAccessor, allBindingsAccessor) { var shouldBeOpen = ko.utils.unwrapObservable(allBindingsAccessor().dialogVisible); $(element).dialog(shouldBeOpen ? "open" : "close"); } }; var viewModel = { label: ko.observable('dialog test'), isOpen: ko.observable(false), open: function() { this.isOpen(true); }, close: function() { this.isOpen(false); } }; ko.applyBindings(viewModel); </code></pre> <p>Problem is error: Error: cannot call methods on dialog prior to initialization; attempted to call method 'close'</p> <p>If I remove setTimeout - applyBindings is applyed to dialog two times.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload