Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does EmberJS have an event which get called after a Handlebars-view has been updated?

This has boggled me for some time, but I managed to keep pushing it forward. Unfortunately, the time has come I really need this.

My question is: Does EmberJS/Handlebars offer an event which gets called when a view is updated and visible in the DOM?

I need to use this event to run some jQuery stuff like addClass, sortable, etc. I've tried using the Live jQuery plugin but it doesn't work with Handlebars. On top of that I assume said event is already in place somewhere, I just can't seem find it.

like image 573
Lennard Fonteijn Avatar asked May 07 '12 15:05

Lennard Fonteijn


1 Answers

Have you had a look at willInsertElement, didInsertElement, and willRerender methods in Ember.View? Also, there are plenty of post here on S.O. that deal with integrating jQuery plugins and frameworks with Ember.

https://github.com/emberjs/ember.js/blob/master/packages/ember-views/lib/views/view.js#L1250-1267

edit/update

After a little back and fourth in the comments, the final solution was to use Ember.run.next. See: http://jsfiddle.net/ud3323/SsRuX/

like image 170
Roy Daniels Avatar answered Oct 02 '22 21:10

Roy Daniels