Created
September 16, 2012 16:04
-
-
Save johnhunter/3732984 to your computer and use it in GitHub Desktop.
Example Knockout composite binding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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