Ember 没有在 hbs 中指定动作如何触发动作
Ember How is action triggered without specifying action in the hbs
在我的 Ember 应用程序组件 my-component.hbs 中,我有
{{#my-grid gridInitialized="gridInstantiated" }}
现在在我的-component.js中,我将其定义为下面的动作;
actions: {
gridInstantiated: function (myGrid) {
}
}
How/Why 上述动作语法是否有效?
具体
- "gridInstantiated" is not defined as normal property in my-component.js
- In the hbs, it is defined without the "action" keyword
只是想知道以上 2 点是如何工作的?
*********编辑************
补充一下,我在 my-grid 组件初始化调用中有以下代码;
this.sendAction('gridInitialized', Ember.$.proxy(this, function () {
this.fetchData();
}));
在经典动作中,为了触发动作,他们将使用 this.sendAction("actionName")
这将在动作中查找 actionName
函数哈希调用具有相应上下文的函数。
中有很好的解释
在我的 Ember 应用程序组件 my-component.hbs 中,我有
{{#my-grid gridInitialized="gridInstantiated" }}
现在在我的-component.js中,我将其定义为下面的动作;
actions: {
gridInstantiated: function (myGrid) {
}
}
How/Why 上述动作语法是否有效? 具体
- "gridInstantiated" is not defined as normal property in my-component.js
- In the hbs, it is defined without the "action" keyword
只是想知道以上 2 点是如何工作的?
*********编辑************
补充一下,我在 my-grid 组件初始化调用中有以下代码;
this.sendAction('gridInitialized', Ember.$.proxy(this, function () {
this.fetchData();
}));
在经典动作中,为了触发动作,他们将使用 this.sendAction("actionName")
这将在动作中查找 actionName
函数哈希调用具有相应上下文的函数。