meetmahpuppy
meetmahpuppy

Reputation: 428

Get current element on {{action}} in emberJS

Can anyone help me to get the element on emberJS {{action}}?

ex.

// application.hbs
<a href="#" {{action 'displayLinks'}}>Get me</a>

// app.js
App.IndexRoute = Ember.Route.extend({
     actions: {
         displayLinks: function() { 
            // returns an object with, no element properties
            console.log(this); 
         }
     }
});

Upvotes: 0

Views: 830

Answers (1)

Gaurav
Gaurav

Reputation: 12796

// application.hbs
<a href="#" id="elementId" {{action 'displayLinks' 'elementId'}}>Get me</a>

// app.js
App.ApplicationRoute = Ember.Route.extend({
     actions: {
         displayLinks: function(id) { 
             console.log($("#" + id)[0]);
         }
     }
});

Upvotes: 1

Related Questions