Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the events Ember.js supports?

Tags:

ember.js

I couldn't find this documented anywhere or answered in any question. The only one I know for certain exists is 'click' (via Handling events with action).

Related questions I've seen (which don't answer my question):

  • Ember events other than click
  • Using Ember.js, how do I run some JS after a view is rendered?
like image 334
Yang Avatar asked Nov 02 '12 00:11

Yang


People also ask

How do I respond to user events in an ember component?

Old Guides - You are viewing the guides for Ember v3.3.0 . VIEW v3.28.0 You can respond to user events on your component like double-clicking, hovering, and key presses through event handlers. Simply implement the name of the event you want to respond to as a method on your component.

How do I respond to user events on my component?

You can respond to user events on your component like double-clicking, hovering, and key presses through event handlers. Simply implement the name of the event you want to respond to as a method on your component. For example, imagine we have a template like this: Let's implement double-clickable such that when it is clicked, an alert is displayed:

How do you handle event objects in a template?

Define the event handler in the component (which is designed to receive the browser event object). Or, assign an action to an inline event handler in the template (which creates a closure action and does receive the event object as an argument). The event handling examples described above respond to one set of events.

Why can’t I define an event parameter in an action?

Since the action is assigned to an inline handler, the function definition can define the event object as its first parameter. The normal behavior for a function defined in actions does not receive the browser event as an argument. So, the function definition for the action cannot define an event parameter.


1 Answers

The supported event names are listed in http://emberjs.com/api/classes/Ember.View.html. Just search for "Possible events names":

Touch events: 'touchStart', 'touchMove', 'touchEnd', 'touchCancel'

Keyboard events: 'keyDown', 'keyUp', 'keyPress'

Mouse events: 'mouseDown', 'mouseUp', 'contextMenu', 'click', 'doubleClick', 'mouseMove', 'focusIn', 'focusOut', 'mouseEnter', 'mouseLeave'

Form events: 'submit', 'change', 'focusIn', 'focusOut', 'input'

HTML5 drag and drop events: 'dragStart', 'drag', 'dragEnter', 'dragLeave', 'drop', 'dragEnd'

like image 87
pangratz Avatar answered Dec 08 '22 13:12

pangratz