vendredi 9 octobre 2015

How to get target element of click event in Ember?

I'm trying to add a modal to Ember app and got this template:

<div class="modal-overlay" {{action "close"}}>
  <div class="modal-body">
    {{yield}}
  </div>
</div>

The problem is that if I click inside body element, the click event bubbles and triggers close action on the overlay. If I try to prevent bubbling by adding an action that doesn't do anything to the body element:

<div class="modal-overlay" {{action "close"}}>
  <div class="modal-body" {{action "nop" bubbles=false>
    {{yield}}
  </div>
</div>

I can't click any links in the body anymore...

What's the best way to solve it? If I could access click event in the close action, I could check if the element clicked was actually the overlay.

Aucun commentaire:

Enregistrer un commentaire