JSFiddle - React, Tailwind, and code Playground
HTML
<div data-bind="htmlTemplate:html"></div>
value:<div data-bind="text:value"></div>
JavaScript
ko.bindingHandlers.htmlTemplate = {
init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
// This will be called when the binding is first applied to an element
// Set up any initial state, event handlers, etc. here
return { controlsDescendantBindings:true };
},
update: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
// This will be called once when the binding is first applied to an element,
// and again whenever any observables/computeds that are accessed change
// Update the DOM element based on the supplied values here.
element.innerHtml=valueAccessor();
}
};
var vm=function(){
value=ko.observable("test value");
this.html=ko.observable("<input data-bind=\"value:inputValue\" type=\"text\"/>")
}
ko.applyBindings(new vm());