我现在已经把头发拉了几个小时,也许有人可以帮助我,我已经阅读了所有的stackoverflow答案,但似乎没有任何工作。
我完全剥离了剑道模板以查看它是否有用,但没有骰子......
我现在已将jsfiddle代码中的所有内容最小化为: http://jsfiddle.net/Lyzz1t1x
(function () {
var app = kendo.observable({
onShow: function () {},
afterShow: function () {}
});
// START_CUSTOM_CODE_home
// Add custom code here. For more information about custom code, see http://docs.telerik.com/platform/screenbuilder/troubleshooting/how-to-keep-custom-code-changes
var test = [{
"code": "1234",
"name": "test1"
}, {
"code": "4525",
"name": "test535"
}, {
"code": "6346",
"name": "dadsd"
}];
app.productlist = {
data: new kendo.data.DataSource({data:test}),
listener: function(e){ console.log('aaaa')}
};
//If no customerid is set navigate to the settings page
app.listener = function (e) {
console.log("Event: " + e.type);
};
kendo.bind($('#main'), app);
// END_CUSTOM_CODE_home
})();
那个人没有工作
这是:
(function () {
var viewModel = kendo.observable();
var test = [{
id: 1,
name: 'Bill',
tasks: ['Task 1', 'Task 2']
}, {
id: 2,
name: 'John',
tasks: ['Task 3']
}, {
id: 3,
name: 'Josh',
tasks: ['Task 4', 'Task 5', 'Task 6']
}];
viewModel.demoData = test;
viewModel.listener = function(e){
console.log('aa');
}
kendo.bind('#container', viewModel);
})();
唯一的区别,一个是使用kendo数据源,但是我需要一个kendo数据源来加载远程json数据,有人可以解释为什么我的click处理程序停止使用kendo数据源吗?
答案 0 :(得分:0)
我通过将varservable放在var app.home中,将数据源放在app.productList中来解决这个问题
(function () {
var app = {};
app.home = kendo.observable({
onShow: function () {},
afterShow: function () {}
});
// START_CUSTOM_CODE_home
// Add custom code here. For more information about custom code, see http://docs.telerik.com/platform/screenbuilder/troubleshooting/how-to-keep-custom-code-changes
var test = [{
"code": "1234",
"name": "test1"
}, {
"code": "4525",
"name": "test535"
}, {
"code": "6346",
"name": "dadsd"
}];
app.productlist = {
data: new kendo.data.DataSource({data:test}),
listener: function(e){ console.log('aaaa')}
};
//If no customerid is set navigate to the settings page
app.listener = function (e) {
console.log("Event: " + e.type);
};
kendo.bind($('#main'), app);
// END_CUSTOM_CODE_home
})();