我有一个 Backbone 应用程序,我在其中创建 2 个视图,一个可拖动,一个可放置。拖动工作正常,但永远不会触发 droppable 回调。如何让可放置视图“看到”可拖动视图?
我的“可丢弃”视图:
class App.Views.Folder extends Backbone.View
template: JST['folders/folder']
className: "folder"
initialize: (options) ->
@collection.on('add', @addOne, @)
@collection.on('reset', @addAll, @)
render: ->
@$el.html(@template(@model.toJSON()))
this.$el.droppable(
drop: -> alert("dropped!")
);
可拖动:
class App.Views.QuestionSet extends Backbone.View
template: JST['question_sets/question_set']
className: "question-set"
initialize: (options) ->
@collection.on('add', @addOne, @)
@collection.on('reset', @addAll, @)
@$el.draggable(
handle: ".drag-question-set"
revert: true
)
render: ->
@$el.html(@template(@model.toJSON()))
更新:
当我将可放置元素插入与$(draggable.el)
可放置视图相同的容器潜水时,可放置元素正确触发回调。当他们在单独的html父母中时,它只是不喜欢它......