【发布时间】:2012-03-19 16:37:55
【问题描述】:
很难调试这个。
在使用 CoffeeScript 的 Backbone 应用程序中使用 jQuery UI Droppable。
该功能没有任何问题,一切都按我的预期工作,但每次删除项目时我仍然会收到此控制台错误。
Uncaught TypeError: Cannot read property 'options' of undefined
droppable 的代码:
@$el.droppable
tolerance: 'pointer'
hoverClass: 'drop_hover'
accept: '.item'
drop: (e, ui) =>
draggedItem = ui.draggable
itemId = draggedItem.attr 'data-id'
allInstances = @model.collection.models
findItems = for instance in allInstances
instanceItems = instance.get 'items'
instanceItems.getByCid itemId
compacted = _.compact findItems
droppedItem = compacted[0]
droppedCollection = droppedItem.collection
droppedCollection.remove droppedItem if _.include droppedCollection.models, droppedItem
@itemCollection.add droppedItem unless _.include @items, droppedItem
就像我说的功能正常工作,如果有人知道我可以尝试调试的任何内容,我只想摆脱错误。
堆栈跟踪
Uncaught TypeError: Cannot read property 'options' of undefined
a.ui.plugin.add.stopjquery-ui.js:49
a.ui.version.a.extend.plugin.call jquery-ui.js:9
a.widget._trigger jquery-ui.js:49
a.widget._mouseStop jquery-ui.js:49
a.widget._mouseUp jquery-ui.js:28
a.widget._mouseUp jquery-ui.js:49
a.widget._mouseDown._mouseUpDelegate jquery-ui.js:28
f.event.dispatch jquery-1.7.1.min.js:3
f.event.add.h.handle.i jquery-1.7.1.min.js:3
感谢您的帮助。
【问题讨论】:
-
错误的堆栈跟踪是否给您任何提示?
-
对我没用。我将其添加到问题中。
-
看起来像一个 jQuery 问题。看看这个forum.jquery.com/topic/…
标签: jquery-ui backbone.js drag-and-drop coffeescript