0
有一個例子in documetation。代碼是here。控制器的計算屬性調用(取決於檢查的屬性)在ember.js
文檔會談是isCompleted控制器的計算性能將與參數至極值調用或者是真或假取決於檢查輸入屬性的值。
控制器如何自動知道輸入的檢查屬性是否改變?我的意思是,當檢查輸入屬性的狀態改變時,控制器的cumputed屬性將會被調用。怎麼運行的?文檔描述了這種行爲?
非常感謝。
有一個例子in documetation。代碼是here。控制器的計算屬性調用(取決於檢查的屬性)在ember.js
文檔會談是isCompleted控制器的計算性能將與參數至極值調用或者是真或假取決於檢查輸入屬性的值。
控制器如何自動知道輸入的檢查屬性是否改變?我的意思是,當檢查輸入屬性的狀態改變時,控制器的cumputed屬性將會被調用。怎麼運行的?文檔描述了這種行爲?
非常感謝。
控制器不知道,輸入幫助程序將複選框綁定到傳入的參數checked
。
{{input type="checkbox" checked=isCompleted class="toggle"}}
http://emberjs.com/guides/templates/input-helpers/
http://emberjs.com/api/classes/Ember.Checkbox.html
Ember.Checkbox = Ember.View.extend({
classNames: ['ember-checkbox'],
tagName: 'input',
attributeBindings: ['type', 'checked', 'indeterminate', 'disabled', 'tabindex', 'name'],
type: "checkbox",
checked: false,
disabled: false,
indeterminate: false,
init: function() {
this._super();
this.on("change", this, this._updateElementValue);
},
didInsertElement: function() {
this._super();
this.get('element').indeterminate = !!this.get('indeterminate');
},
_updateElementValue: function() {
set(this, 'checked', this.$().prop('checked'));
}
});
請仔細看問題。你的答案根本不對。 –
我讀到的問題很好,我沒有看到它在控制器上定義,以及你發送的模型和鏈接談論綁定頂部屬性。答案仍然存在。 – Kingpin2k
來自文檔的引用:「當這個{{input}}被渲染時,它會詢問控制器isCompleted屬性的當前值。當用戶點擊這個輸入時,它會調用控制器的isCompleted屬性,其參數爲true或取決於輸入的新選中值。那麼你怎麼能說控制器不知道被檢查狀態的改變? –