在调试此程序时遇到困难。
在使用CoffeeScript的Backbone应用程序中使用jQuery UI Droppable。
该功能没有任何问题,一切都按照我的预期进行,但是每次删除项目时,我仍然会收到此控制台错误。
Uncaught TypeError: Cannot read property 'options' of undefined
可转换代码:
@$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
谢谢你的帮助。
最佳答案
似乎终于可以在v1.11.0中正确解决此问题,而没有在此建议所有解决方法:
似乎现在删除原始的可拖动项目将不会导致此错误,因为属性现在存储在
instance
字段中。我已经确认v1.11.0可以修复在v1.10.4上弹出的确切错误。
关于jquery-ui - jQuery UI Droppable未捕获TypeError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9774111/