在这个 plunker 示例中,详细视图的数据绑定在第一次显示时起作用,但在导航到其他项目时不会更新。
什么不见了 ?谢谢!
html:
<body>
<div data-role="view" data-model="aViewModel" id="aView">
<div data-role="header">
<div data-role="navbar">
<span data-role="view-title">Master</span>
</div>
</div>
<ul data-role="listview" data-style="inset"
data-bind="source: items, events : { click : onClickItem}"
data-template="itemsTemplate">
<script id="itemsTemplate" type="text/html" >
<a href="##">#:name#</a>
</script>
</ul>
</div>
<div data-role="view" id="aDetailView"
data-model="aViewModel.currentItem"
data-show="aViewModel.onDetailViewShow">
<div data-role="header">
<div data-role="navbar">
<span data-role="view-title" data-bind="text:name"></span>
<a data-align="left" data-role="backbutton">Back</a>
</div>
</div>
<ul data-role="listview" data-style="inset" >
<li>Name <span data-bind="text: name"></span></li>
<li>Value <span data-bind="text: value"></span></li>
</ul>
</div>
<script src="script.js"></script>
JS:
var app = new kendo.mobile.Application(document.body );
ViewModel = function () {
var self = this;
function Item (name, value)
{
this.name = name;
this.value = value;
}
self.items = new kendo.data.DataSource({
data: [
new Item("AAA",1),
new Item("BBB",2),
new Item("CCC",3)
]
});
self.currentItem = null;
self.onClickItem = function(e) {
e.preventDefault();
self.set("currentItem", e.dataItem);
app.navigate("#aDetailView", "slide");
}
self.onDetailViewShow = function(e) {
}
self = kendo.observable(this);
return self;
};
var aViewModel = new ViewModel();