user4412054
user4412054

Reputation:

Ember.js, Performances, Performances: <button onclick=(action 'someAction')> VS <button {{action 'someAction'}}>

In this amazing video (https://www.youtube.com/watch?v=udix3GZouik) Alex Blom talks about "hacks" in Ember for mobile world.

At 22:00 he says something about <button onclick=()> vs simply {{action}}.

enter image description here

Can you say something more about this? What he really means? Is today still like this?

It works just for <button> tag? And for <a>?

Upvotes: 1

Views: 119

Answers (1)

ykaragol
ykaragol

Reputation: 6221

For your first question:

Action helper has two different usage: As normal helper and as closure action.

This usage is closure action usage:

<div onclick={{action "save"}}></div>

While this is event attachment usage:

<div {{action "save"}}></div>

For your second question:

In the "Specifying DOM event type" section of the ember documentation about action helper, it is described as:

By default the {{action}} helper registers for DOM click events.

But if you can override this behaviour by passing on parameter as below:

<div {{action "anActionName" on="doubleClick"}}>

To read more:

  1. Read the guides about action helper
  2. This is an excellent blog about closure actions.

Upvotes: 1

Related Questions