I building a ember.js app that also ties into some other jQuery plugins. I have some form fields that I need to call a jQuery plugin against once the view is rendered. I've tried hooking into didInsertElement
, but apparently the values for the bound form fields are not assigned at insertion. Is there a callback in existence for when the view completely renders or when bindings are initialized?
ie.
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 the values of .some-class
are a not set yet.
I don't want to use a setTimeout
and create a race condition.
Well, what is going on, is that the testValue binding is updated after the view is inserted. So what you can do is to call
$('.silly-field').doSomethingSilly();
inside anEmber.run.next()
function.As written in the docs: