我想在Kendo移动应用程序(即不是MVC)中分离我的视图和ViewModels。我在ViewModel中有一个远程数据源并且无法让它工作 - 我确信它是简单的(我无法找到在ViewModel中使用远程数据源的Kendo示例 - 它全部是内联的(http://demos.telerik.com/kendo-ui/web/mvvm/remote-binding.html,http://docs.telerik.com/kendo-ui/getting-started/framework/datasource/overview) (e){var n = this; return e === t?n._data:(n._data = this._observe(e),n._ranges = [],n ._addRange(n._data),n._total = n._data.length,n._process(n._data)中,t)}”,而不是实际数据。远程数据源和远程视图+ MVVM
games.html查看
<div id="tabstrip-home"
data-role="view"
data-title="Games"
data-model="app.gamesService.viewModel">
<ul class="games-list"
data-bind="source: gamesDataSource"
data-template="template">
</ul>
</div>
<script type="text/x-kendo-template" id="template">
<div class="product">
<h3>#:ProductName#</h3>
<p>#:kendo.toString(UnitPrice, "c")#</p>
</div>
</script>
个games.js视图模型
(function (global) {
var GamesViewModel, app = global.app = global.app || {};
GamesViewModel = kendo.data.ObservableObject.extend({
gamesDataSource: new kendo.data.DataSource({
transport: {
read: {
url: "http://demos.telerik.com/kendo-ui/service/Products",
dataType: "jsonp"
}
}
})
});
app.gamesService = {
viewModel: new GamesViewModel()
};
})(window);
PS读了 - 我真的不明白这里的区别 - kendo.data.ObservableObject.extend这个代码第2位似乎被延长初始化事件 - 我真的需要在另一个事件上公开远程数据源(例如,点击一个按钮) – Rodney