1

I have a div which should execute the method speak on click:

Corresponding Action Helper:

<div {{action speak}}>Say</div>

If it were to execute the method wiggle on mouse enter:

Corresponding Action Helper:

<div {{action wiggle on="mouseEnter"}}>Say</div>

Now I want to combine both, I want it to execute speak on click as well as execute wiggle on mouseEnter

what would be the corresponding {{action}} helper ?

Your Attention !

I know the following would work:

App.MultiEventView = Ember.View.extend({
  click: function(){
    /* some code */
  },
  mouseEnter: function(){
    /* some code */
  }
})

{{ view App.MultiEventView }}

But can we define multiple events using action helper instead of defining the view ?

4

1 回答 1

0

Not on the same div. {{action}} translates to a data-ember-action attribute on the element, and there's no mechanism for overloading that for more than one action.

What you can do is wrap your div in another div with the second action.

于 2013-03-16T20:10:09.973 回答