JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://cdnjs.cloudflare.com/ajax/libs/knockout/2.3.0/knockout-min.js"></script>
<div id = "trol">
<button data-bind="click: addTemplate">Add Template</button>
<button data-bind="click: doAlert">Test Alert</button>
</div>
<script type="text/html" id="MyTemplate">
<div id="container">
<a href="#" data-bind="click: $root.doAlert">Do Alert</a>
</div>
</script>
CSS
#container
{
background-color: grey;
}
JavaScript
function MyViewModel()
{
self = this;
self.addTemplate = function ()
{
var newElement = $($("#MyTemplate").html()).appendTo("body");
ko.applyBindings(self, newElement[0]);
}
self.doAlert = function()
{
alert('Hello World');
}
}
ko.applyBindings(new MyViewModel());