我想用Ember.js和jQuery UI的可拖动功能一起使用,但是我遇到了问题。具体来说,当使用帮助器时,我无法删除元素,一切都非常缓慢。如果我不使用克隆助手,一切都按预期工作。Ember.js + jQuery UI可拖动的克隆
我怀疑这与jQuery UI克隆html,包括所有metamorph脚本标记(用于绑定)有关。
我不需要在拖动它时更新现场元素。有没有办法用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
任何帮助将不胜感激。
那么,你如何重新启用绑定后?或者你不关心这个吗? – 2012-01-10 03:05:40
仅在用于拖拽帮助程序的克隆元素中禁用绑定。原始元素保持完好 – ghempton 2012-01-10 03:16:40
啊,有你了。那么我想不出任何内置的东西来做你正在尝试做的事情。你看起来像一个干净的解决方案给我。 – 2012-01-10 03:24:57