Created
May 21, 2013 17:48
-
-
Save andrewburgess/5621777 to your computer and use it in GitHub Desktop.
KnockoutJS binding that clears out the initial element before applying the template. Allows for server side generation of a repeatable element, that can then be rebound with Knockout
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
ko.bindingHandlers.templateWithClear = { | |
init: function (element, valueAccessor) { | |
element.innerHTML = ''; | |
return ko.bindingHandlers.template.init(element, valueAccessor); | |
}, | |
update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { | |
return ko.bindingHandlers.template.update(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment