0

我已经把头发拉出来几个小时了,也许有人可以帮助我,我已经阅读了所有的 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
})();

那个不工作

这个是:

http://jsfiddle.net/qd2sr9y6

(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);

})();

唯一的区别是使用剑道数据源,但我需要剑道数据源来加载远程 json 数据,谁能解释为什么我的点击处理程序停止使用剑道数据源?

4

1 回答 1

0

我通过将可观察对象放入 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
})();

http://jsfiddle.net/L1b6abjy/

于 2016-08-11T11:20:54.573 回答