【发布时间】:2016-02-24 13:44:57
【问题描述】:
我是淘汰赛和萨米的新手。我正在使用 Sammy(router) 和 KnockOut(binding) 实现 SPA。
我有以下代码。
this.get('#/Page/:operation', function (context) {
this.partial('templates/Page1.html', { cache: false }).then(function (content) {
// the first argument to then is the content of the
// prev operation
$('#sammyDiv').html(content);
});
});
当我检查控制台时,它显示 “您不能多次将绑定应用到同一个元素。(...)”。
我在这里做错了吗?
Partial 和 Render 有什么区别?
【问题讨论】:
-
这看起来很麻烦。 Knockout 不仅仅是“绑定”,它是一个通过模型控制整个 DOM 的系统。如果您在模型之外进行 DOM 操作,您将遇到问题。我建议你看看使用 Knockout 组件的 Sammy 路线。您没有在此处显示您调用
ko.applyBindings的位置,但这就是生成您收到的错误消息的原因。
标签: html knockout.js sammy.js