嗨,我有一个使用敲除和 pagerjs 的单页应用程序的小问题。
在我的 index.html 我有
<div class="container" style="padding-top: 30px;" id="container">
<span id="span" onclick = 'clickme(this)'>
I am span
</span>
<div data-bind="page: {id: 'start' , title : 'First Page'}">
you are currently viewing the content of first page.
<br />
<a href="#!/start/deep">
first child
</a>
<br />
<a href="#!/start/second">
second child
</a>
<br />
<br />
<div data-bind="page: {id: 'deep', title : 'Second Page',role: 'start', source: 'views/test1.html'}">
you are currently viewing the content of first page inside First Page.
<br />
<a data-bind="page-href :'../second'" >
Second Child
</a>
</div>
<div data-bind="page: {id: 'second', title : 'Second Page', source: 'views/test.html'}">
you are currently viewing the content of second page inside Second Page.
<br />
<a data-bind="page-href :'../deep'" >
First Child
</a>
</div>
<br />
<br />
<br />
<a href="#!/structure">
Go to Structure
</a>
</div>
<div data-bind="page: {id: 'structure', title : 'Second Page'}">
you are currently viewing the content of second page.
<br />
<a href="#!/start">
Go to Start
</a>
</div>
</div>
我在索引页面上的 javascript 看起来像这样
function PagerViewModel(){
var self = this;
}
$(function () {
pager.Href.hash = '#!/';
pager.extendWithPage(PagerViewModel.prototype);
ko.applyBindings(new PagerViewModel(), document.getElementById("container"));
pager.start();
});
在 test.html 文件中我有
<div id="two">
......
</div>
<script type="text/javascript">
........
var viewModel = new PointPageModel([
{ name: "page1"},
{ name: "page2"},
{ name: "page3"},
{ name: "page"}
]);
ko.applyBindings(viewModel, document.getElementById("two"));
</script>
我仍然收到错误:您不能将绑定多次应用于同一个元素。我不是绑定到不同的元素吗?任何建议将不胜感激。
最好的问候,加弗里尔