I created a knockoutjs plugin that ultimately uses ko.renderTemplate to βupdateβ this binding handler. The code generates the expected result, but also generates the error "Unable to parse bindings."
A reproduction of this problem can be found here http://jsfiddle.net/rhoadsce/VSWK2/ in jsfiddle.
javascript is as follows:
ko.plugin = function(configuration) {
var self = this;
self.content = configuration.content || '';
};
ko.bindingHandlers.plugin = {
update: function(element, valueAccessor, allBindingsAccessor) {
var viewModel = valueAccessor();
$(element).append('<div id="pluginContainer"></div>');
var $container = $(element).children('#pluginContainer');
ko.renderTemplate("pluginTemplate", viewModel, {}, $container, 'replaceNode');
}
};
$(function () {
var vm = (function() {
var plugin = new ko.plugin({ content: 'test content'});
return {
plugin: plugin
}
})();
ko.applyBindings(vm);
});
html is equally simple.
<div data-bind="plugin: plugin"></div>
<script id="pluginTemplate" type="text/html"><span data-bind="text: content"></span></script>
source
share