jQuery UI button
http://www.knockmeout.net/2011/07/another-look-at-custom-bindings-for.html
by rniemeyer
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/base/jquery-ui.css">
<script src="http://rniemeyer.github.com/KnockMeOut/Scripts/jquery.tmpl.js"></script>
<script src="http://knockoutjs.com/downloads/knockout-2.2.1.debug.js"></script>
<button data-bind="click: greet, jqButton: { icons: { primary: 'ui-icon-gear' } }">Test</button>
JavaScript
ko.bindingHandlers.jqButton = {
init: function(element, valueAccessor) {
var options = valueAccessor() || {};
$(element).button(options);
//handle disposal (if KO removes by the template binding)
ko.utils.domNodeDisposal.addDisposeCallback(element, function() {
$(element).button("destroy");
});
}
};
var viewModel = {
greet: function() {
alert("Hello");
}
};
ko.applyBindings(viewModel);