Skip to content

Instantly share code, notes, and snippets.

@johnhunter
Created September 16, 2012 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnhunter/3732984 to your computer and use it in GitHub Desktop.
Save johnhunter/3732984 to your computer and use it in GitHub Desktop.
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