【发布时间】:2012-02-06 12:45:31
【问题描述】:
我正在尝试将 Ember.js 与 jQuery UI 的可拖动功能结合使用,但我遇到了问题。具体来说,当使用 clone 助手时,我无法删除该元素并且一切都非常滞后。如果我不使用克隆助手,一切都会按预期进行。
我怀疑这与 jQuery UI 克隆 html 有关,包括所有的变形脚本标签(用于绑定)。
我不需要在拖动元素时实时更新它。有没有办法用 ember 去除绑定标签?
供参考,这里是视图逻辑:
didInsertElement: ->
@_super()
@$().draggable
cursor: 'hand'
helper: 'clone'
opacity: 0.75
scope: @draggableScope
@$().droppable
activeClass: 'dropActive'
hoverClass: 'dropHover'
drop: @createMatch
scope: @droppableScope
我的第一个想法是在拖动过程中尝试使用beginPropertyChanges 和endPropertyChanges 来防止意外行为。这似乎不起作用,也不是理想的,因为我希望更新其他绑定。这是我尝试过的修改后的代码:
didInsertElement: ->
@_super()
@$().draggable
cursor: 'hand'
helper: 'clone'
opacity: 0.75
scope: @draggableScope
start: ->
Ember.beginPropertyChanges()
stop: ->
Ember.endPropertyChanges()
@$().droppable
activeClass: 'dropActive'
hoverClass: 'dropHover'
drop: @createMatch
scope: @droppableScope
任何帮助将不胜感激。
【问题讨论】: