このコードを使用すると、dom ノードがすでにノックアウトにバインドされているかどうかをテストできます。
次のようにバインディングを 2 回目に適用する前に、これを確認する必要があります。
if(!isBound) applybinding を呼び出します...
これは本当に私がすべき方法ですか?
フレームワークがこれを処理しないのはなぜですか?
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'));
});
});