Created
November 3, 2014 10:53
-
-
Save juliankrispel/f563b18107a5016b0ea0 to your computer and use it in GitHub Desktop.
knockout.js component template function
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
// Add component | |
var inputComponentLoader = { | |
loadComponent: function(name, config, callback) { | |
if(u.isType(config.template, 'function')){ | |
var template = ko.utils.parseHtmlFragment(config.template(config)); | |
callback({ | |
template: template, | |
createViewModel: createViewModelForInput | |
}); | |
}else{ | |
callback(null); | |
} | |
} | |
}; | |
// Register it. Make it take priority over the default loader. | |
ko.components.loaders.unshift(inputComponentLoader); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment