我有此代码,当单击图标编辑时,它会启动一个操作,但同时,点击范围传播到下面的视图(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}}
也可以将bubbles=false
参数添加到action
标签。有关如何配置事件传播,请参见API文档。
尝试修改操作:
modalOpen: function {
//code of your action
return false;
}
这在类似情况下对我有用
实现这一目标的辛烷值方法是使用ember-event-helpers addon的stop-propagation
助手。
<span class="inline pull-right icon-edit" {{on "click" (stop-propagation (queue this.modalOpen this.modifyPersonPopup this.modifyPerson))}}></span>