javascript - Disable\Enable Bootbox button with KO -


i'm using bootbox confirm dialog custom message template bound ko observables. wish compute obsrvables content , enable "ok" confirm button when computed returns true.

at moment have js:

self.name = ko.obsevable(): var messagetemplate = $("#add-template").html(); ko.applybindings(self, messagetemplate);  bootbox.confirm({                 title: "add new",                 message: messagetemplate,                 callback: function (value) {                         //                     }                 }             } 

and 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, wish enable bootbox "ok" button when "name" input validated (with costume validation function)

is possible? thanks!

well finaly got it. here answer :)

http://jsfiddle.net/6vb7e224/5/

var viewmodel = function () {     var self = this;     self.name = ko.observable();      self.select = function () {         var messagetemplate = $($("#add-template").html());         ko.applybindings(self, messagetemplate.get(0));         messagetemplate.show();          bootbox.dialog({                 title: "add new",                 message:  messagetemplate,                 callback: function (value) {                  },                 buttons: {                     render: {                         disabled: "false",                         label: "render",                         classname: "btn-success",                         callback: function() {                             return false;                         }                     },                     overrride: {                         label: "override",                         classname: "btn-primary",                         callback: function() {}                     },                 }             });      } }   ko.applybindings(new viewmodel()); 

Comments

Popular posts from this blog

c++ - OpenMP unpredictable overhead -

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

javascript - Wordpress slider, not displayed 100% width -