停止从Ember操作的点击传播? [英] Stop click propagation from Ember action?
问题描述
我有这个代码,当icon-edit span被点击时,它触发一个动作打开一个模态,但是,同时,点击传播到它下面的视图(personView)。我想要动作执行和停止传播。
I have this code that when icon-edit span is clicked, it fires an action that opens a modal, however, at the same time, the click propagates to the view below it (personView). I want the action to execute and stop the propagation.
我可以想到的唯一解决方案是让图标编辑自己的视图,并停止点击传播返回false在方法点击。有没有其他方法这样做,而不再另一个观点?
The only solution I can think of is to make the icon-edit its own view and stop the click propagation by returning false in method click. Is there any other way of doing this without making another view?
HBS:
{{#view Blocks.PersonView}}
<span class="inline pull-right icon-edit" {{action 'modalOpen' 'modifyPersonPopup' 'modifyPerson' this}}></span>
<p class="inline pull-left person-name">{{firstNameDelayed}}</p>
{{/view}}
推荐答案
您可以将 bubbles = false
参数添加到操作
标记(请参阅 http://emberjs.com/api/classes/Ember.Templates.helpers.html#toc_event-propagation )
Also you can add bubbles=false
parameter to action
tag (see http://emberjs.com/api/classes/Ember.Templates.helpers.html#toc_event-propagation)
这篇关于停止从Ember操作的点击传播?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!