我已經做了選擇了一個樣本Ember.js集成(https://github.com/harvesthq/chosen)Ember.js所選的積分
的CoffeeScript:
App.ChosenSelectView = Em.Select.extend({
didInsertElement: ->
@_super()
@$().chosen()
# Assumes optionLabelPath is something like "content.name"
@addObserver(@get("optionLabelPath").replace(/^content/, "[email protected]"), -> @contentDidChange())
contentDidChange: ->
# 2 ticks until DOM update
Em.run.next(this, (-> Em.run.next(this, (-> @$().trigger("liszt:updated")))))
})
事情困擾我的是,我沒有多少時間做我所選擇的插件觸發更新前需要一個好主意。從我的實驗來看,2個運行循環是可以的,但是對於整個事情來說也許有更好的辦法?在的jsfiddle
完整的示例:http://jsfiddle.net/oruen/qfYPy/
我不知道是否有你需要的一切Ember.ru *在你的代碼中調用。我刪除它們,它的工作原理。我錯過了什麼 ? – 2012-04-03 07:19:10
感謝您的回答,我認爲run.sync()方法更好,然後在完成同步之前猜測循環數。 – oruen 2012-04-03 12:59:44