【发布时间】:2014-05-29 02:24:10
【问题描述】:
我遵循了 Ember.js 的 Using Modal Dialogs 并在 ApplicationRoute 中放置了一个动作处理程序。在我尝试在组件的模板中使用相同的操作之前,效果很好,在这种情况下,它不会在控制台中执行以下错误:Uncaught Error: Assertion Failed: Thetargetfor <appkit@component:user-info::ember451> (49.5) does not have asendmethod。
Here's 一个展示我的问题的 JSBin。注意在索引模板中指定的动作如何调用模态,而在组件中指定的动作却没有。 JSBin 的要点是这样的:
索引模板
<!-- this creates the modal successfully -->
<button {{action "openModal" "modal-login"}}>open a modal (not in a component)</button>
<!-- this component has the same button as above in code, but clicking the button doesnt work -->
{{user-info}}
用户信息组件模板
<button {{action "openModal" "modal-login"}}>open a modal(in a component)</button>
我已经找到了解决这个问题的方法,但是它非常hacky,并且在我的组件中添加了很多代码。在组件声明中,我复制了“openModal”操作,并通过组件上的注册操作like so 使其发送操作。
【问题讨论】:
标签: javascript ember.js