Ember.js Ember.View didRender event

I am creating an ember.js application that also communicates with some other jQuery plugins. I have some form fields that I need to call the jQuery plugin against how the view is rendered. I tried to connect to didInsertElement , but apparently the values ​​for the fields of the associated form are not assigned when pasting. Is there a callback for when the view is fully displayed or when the bindings are initialized?

t

 MyView: Ember.View.extend #Boaring normal stuff here didInsertElement: -> $('.some-class').doSomething() 

and

 {{view Ember.TextField valueBinding="someField" class="some-class"}} 

Does not work because .some-class values ​​are not set yet.

I do not want to use setTimeout and create race conditions.

+1
source share
1 answer

Well, what happens is that the testValue binding is updated after the view is inserted. So you can call $('.silly-field').doSomethingSilly(); inside the Ember.run.next() function.

As written in the docs:

 Ember.run(myContext, function(){ // code to be executed in the next RunLoop, which will be scheduled after the current one }); 
+4
source

All Articles