I'm using a bootbox confirm dialog with a custom message template that is bound to ko observables. I wish to compute the obsrvables content and enable the "ok" confirm button only when the computed returns true.
At the moment I have this js:
self.name = ko.obsevable():
var messageTemplate = $("#add-template").html();
ko.applyBindings(self, messageTemplate);
bootbox.confirm({
title: "Add new",
message: messageTemplate,
callback: function (value) {
// do something
}
}
}
And this html:
<div id="add-template" style="display:none">
<form role="form">
<div class="row">
<div class="col-xs-8">
<div class="form-group">
<input data-bind='value: name, valueUpdate: "afterkeydown"' placeholder="Name">
</div>
</div>
</div>
</form>
</div>
And it's working fine, but I wish to enable the bootbox "ok" button only when the "name" input is validated (with a costume validation function)
Is it possible? Thanks!
Well finaly i got it. Here is the answer :)
http://jsfiddle.net/6vb7e224/5/