With this code I can test wether a dom node is already bound with knockout.
I should check this before I apply the binding a 2nd time like:
if(!isBound) call applybinding...
Is this really how I should do it?
Is there no cleaner way and why is the framework not handling this for me?
var isBound = function() {
return !!ko.dataFor(document.getElementById("orderView")));
};
var app = sammy(function () {
this.get('#/orders', function () {
var ovm = new OrderViewModel();
ko.applyBindings(ovm , document.getElementById('orderView'));
});
this.get('#/customers', function () {
var cvm = new CustomerViewModel();
ko.applyBindings(cvm , document.getElementById('responseView'));
});
});