jeudi 30 juillet 2015

Run controller event after render in Ember without View

I'm new with Ember and what I want to do is execute some initialization with jQuery like this: Ember.$("select").selectpicker(); to customize default select (it actually inserts div that represents the hidden select). I used to have this code in my Controller:

init() {
   this._super();
   Ember.run.schedule("afterRender", this, function() {
      this.send("initializeJQuery");
   }
});
actions: {
   initializeJQuery() {
      Ember.$("select").selectpicker();
   }
}

It really initializes my select tags, but when I transition to another route and go back – it rerenders and doesn't want to call initializeJQuery method despite the run method (not runOnce). I use Ember v1.13 and Views are deprecated so I'm looking for alternative way to do this.

Hope for your help.




Aucun commentaire:

Enregistrer un commentaire