I found a great example here: http://jsfiddle.net/63tGP/39/ (from this question: Knockout bootstrap modal issue) that allows a user to add items to a hierarchy by opening a bootstrap modal. The key was to use a knockout binding handler.
I would like to do this, only use a jquery-ui dialog instead. I've modified the fiddle, here: http://jsfiddle.net/63tGP/40/ ; only I get very strange results. Can someone please help me settle this out?
I've modified the binding handler, as such:
ko.bindingHandlers.showModal = {
init: function (element, valueAccessor) {
$(element).dialog({ backdrop: 'static', keyboard: true, show: false });
},
update: function (element, valueAccessor) {
var value = valueAccessor();
if (ko.utils.unwrapObservable(value)) {
$(element).dialog('open');
$("input", element).focus();
}
else {
$(element).dialog('close');
}
}
};
The end goal is to create a simple, reusable component I can use for different levels of my hierarchy, for adding and editing an object.
Thanks!