[英]Ember.js Ember.View didRender event
我構建了一個ember.js應用程序,它也與其他一些jQuery插件相關聯。 我有一些表單字段,我需要在呈現視圖時調用jQuery插件。 我已經嘗試掛鈎到didInsertElement
,但顯然綁定表單字段的值在插入時沒有分配。 當視圖完全呈現或綁定初始化時是否存在回調?
即。
MyView: Ember.View.extend
#Boaring normal stuff here
didInsertElement: ->
$('.some-class').doSomething()
和
{{view Ember.TextField valueBinding="someField" class="some-class"}}
不起作用,因為.some-class
的值尚未設置。
我不想使用setTimeout
並創建競爭條件。
那么,發生了什么,是在插入視圖后更新testValue綁定。 所以你可以做的就是調用$('.silly-field').doSomethingSilly();
在Ember.run.next()
函數中。
如文檔中所述:
Ember.run(myContext, function(){
// code to be executed in the next RunLoop, which will be scheduled after the current one
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.