2016-08-09 63 views
0

我一直拉我的頭髮幾個小時現在,也許有人可以幫我,我已經閱讀所有的stackoverflow答案,但似乎沒有工作。Kendo UI模板點擊綁定不工作telerik平臺

我剝了下來劍道模板完全看它是否有幫助,但沒有骰子..

現在我已經最小化所有的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 
})(); 

那一個ISN不工作

這一個是:

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數據,任何人都可以解釋爲什麼我的點擊處理程序停止與劍道數據源的工作?

+0

你可以給我的jsfiddle工作示例。請 –

+0

您好,的jsfiddle:HTTPS://jsfiddle.net/Hd47F/221/ 如果移動按鈕劍道模板外,將工作 –

+0

現在我已經最小化所有的jsfiddle代碼如下: https://開頭的jsfiddle .net/Lyzz1t1x/ 那一個沒有工作,這個是: http://jsfiddle.net/qd2sr9y6/ 唯一的區別,一個是使用kendo數據源,但我需要一個kendo數據源來加載遠程json數據,任何人都可以解釋爲什麼我的點擊處理程序不使用劍道數據源? –

回答

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/