停止点击Ember动作的传播?

Jai*_*ime 16 javascript view click ember.js

我有这个代码,当单击图标编辑范围时,它会触发一个打开模态的动作,但同时,单击会传播到它下面的视图(personView).我希望动作执行并停止传播.

我能想到的唯一解决方案是使图标编辑自己的视图并通过在方法点击中返回false来停止点击传播.没有其他观点,还有其他方法可以做到这一点吗?

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}}
Run Code Online (Sandbox Code Playgroud)

小智 39

您还可以向bubbles=false参数添加参数action(请参阅http://emberjs.com/api/classes/Ember.Templates.helpers.html#toc_event-propagation)


小智 6

尝试修改操作:

modalOpen: function {
    //code of your action
    return false;    
}
Run Code Online (Sandbox Code Playgroud)

在类似的情况下,这对我有用