Rick Moss
Rick Moss

Reputation: 926

make emberjs event only get called once

I have a app that has items that can contain child items and so on.

Each item has a mouseDown event that i want to be able to use to click and select an item.

The problem is that when i click a child item the parents mouseDown event is also being called.

How do i stop this so the mouseDown event only gets called once or if thats not posible i actually want the function called within the mouseDown event to only get called once.

Here is a jsfiddle to very simply show this. http://jsfiddle.net/rmossuk/W9vmW/1/

If you click no the Click here its mouse down event gets called twice.

Upvotes: 2

Views: 1154

Answers (2)

korCZis
korCZis

Reputation: 580

Or you can you use event.stopPropagation(). I updated your fiddle, see http://jsfiddle.net/W9vmW/2/.

There is more informations about how event bubbling in ember works here - http://emberjs.com/guides/view_layer/#toc_event-bubbling

Events will bubble up the view hierarchy until the event reaches the root view. An event handler can stop propagation using the same techniques as normal jQuery event handlers:

return false from the method event.stopPropagation

Upvotes: 0

sly7_7
sly7_7

Reputation: 12011

You have to return false; in the mouseDown function.

Upvotes: 3

Related Questions