jquery-ui - jQuery UI Droppable未捕获TypeError

标签 jquery-ui backbone.js drag-and-drop coffeescript

在调试此程序时遇到困难。

在使用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中正确解决此问题,而没有在此建议所有解决方法:

http://bugs.jqueryui.com/ticket/6889



似乎现在删除原始的可拖动项目将不会导致此错误,因为属性现在存储在instance字段中。我已经确认v1.11.0可以修复在v1.10.4上弹出的确切错误。

关于jquery-ui - jQuery UI Droppable未捕获TypeError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9774111/

相关文章:

jquery - jQuery 的 'Selectmenu' 的自定义样式

javascript - 可在所有可能的地方放置

Android ListViewAnimations - 无法在 DynamicListView 中交换项目

javascript - Backbone : how to get and display just one model data in a view via router

javascript - Backbone - 当用户通过特定帖子访问网站时如何管理集合初始化?

javascript - 为什么 backbone.js model.save() 会改变属性散列?

jquery - 检查 div 是否包含 jQuery 中的元素

jQuery 自动完成 : On select parse other key from the same array

javascript - 同一表单上的多个日期选择器

Jquery UI 可排序,按钮不能用作句柄