Stop click propagation from Ember action?

筅森魡賤 提交于 2019-12-04 02:47:13

问题


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.

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}}

回答1:


Also you can add bubbles=false parameter to action tag. See the API documentation for how to configure event propagation.




回答2:


Try to modify the action:

modalOpen: function {
    //code of your action
    return false;    
}

This worked for me in a similar situation



来源:https://stackoverflow.com/questions/22230430/stop-click-propagation-from-ember-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!