我是Ember的新手,我試圖做一個簡單的演示應用程序,其中列表按鈕被按下時使用不同的數據重新渲染。在ember.js中重新綁定模型到列表中的問題
這是我嘗試的一個運行實例,按SHOW LIST按鈕顯示鳴叫名單,並結合工作正常,第一次:http://jsfiddle.net/0xnpav6L/21/
以下是在代碼中的兩個地方我我試圖將模型重新綁定到列表中:
1)在ApplicationController中 - 我嘗試將bindNewModel操作綁定到MODIFY按鈕,但似乎沒有工作。
2)在ListController中 - 嘗試綁定bindNewModel動作到所有列表項(當按下任何列表項時),但也似乎沒有工作。
App.ApplicationController = Ember.ObjectController.extend({
actions: {
bindNewModel: function() {
console.log(App.ListController);
this.set('model', renderTweets());
}
}
});
App.ListController = Em.ArrayController.extend({
init: function() {
this.set('model', renderTweets());
},
actions: {
bindNewModel: function() {
this.set('model', renderTweets());
}
}
});
任何幫助都會被處理。
如果你新來的燼,爲什麼你使用燼1.8「?您正在使用的很多模式在最新的2.12版ember版本中被刪除/棄用。 – Lux
不,你沒有。這仍然是'1.8'。檢查資源面板。你的代碼甚至不會用'2.12'運行。像'ArrayController'之類的東西從'2.0'開始從燼中移除。另外請注意,您到'2.12'的鏈接無效。您的整個代碼都建立在過時的示例/教程上。檢查'ember-cli',最新的ember版本的指南,'ember-twiddle'而不是小提琴,並且可能加入閒置頻道[尋求幫助。在這裏你可以找到一個鏈接。](https://emberjs.com/community/) – Lux