Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example Knockout composite binding
/*
an example of how we can reuse common sets of bindings
by wrapping them in a single custom binding
*/
ko.bindingHandlers.myCompositeBinding = {
init: function(element, valueAccessor, allBindingsAccessor, vm){
ko.applyBindingsToNode(element, {
text: vm.text,
hidden: vm.isHidden,
click: function(data, event){ vm.activated(data); }
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.