I'd like to add a class to a specific HTML element based on whether it's the selected one at the time. It's selected based on the current page.
For some reason, I'm having a hard time finding how to do that.
Is there a hook or an event that I should look for?
Here's my route:
App.OptionRoute = Ember.Route.extend({
model: function(params) {
return this.modelFor('simpleSearch')[params.question_id];
},
actions: {
select: function(optionId) {
console.log("Option Route");
console.log(optionId);
}
}
});
How would I grab params.question_id
and then use that to add the class to my element?
Should this be done in the class for the view instead?
Thanks!
In Ember you should avoid programmatically modifying the DOM. If you need to reference the current question_id from within a class element, you should use bind-attr to bind the question_id to the class from your handlebars template.