Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery ui 删除主干关系集合中未发生的事件_Jquery Ui_Backbone.js_Backbone Relational - Fatal编程技术网

Jquery ui 删除主干关系集合中未发生的事件

Jquery ui 删除主干关系集合中未发生的事件,jquery-ui,backbone.js,backbone-relational,Jquery Ui,Backbone.js,Backbone Relational,下面的代码位于渲染函数中的主干视图中。我正在使用Backbone.Relational和jQueryUI可排序 var scopedThis = this; // make this container a sortable container this.$el.sortable({ connectWith: '.wlProductsInRoomContainer', revert: true, stop: function(){ scopedThis.

下面的代码位于渲染函数中的主干视图中。我正在使用Backbone.Relational和jQueryUI可排序

var scopedThis = this;

// make this container a sortable container
this.$el.sortable({
    connectWith: '.wlProductsInRoomContainer',
    revert: true,
    stop: function(){
        scopedThis.getNewSortOrders();
},
receive: function(e, r){

    // get model from newly passed in product
    var prodModel = r.item.data().productView.model;

    // add model to this collection but pass silent so collection add event doesn't get ran
    scopedThis.collection.add(prodModel, { silent: true });

},
remove: function (e, r){

    // get model from product that has left this sortable
    var prodModel = r.item.data().productView.model;

    // remove this model from this collection
    scopedThis.collection.remove(prodModel);

    console.log(scopedThis.collection);

}
});

问题发生在可排序删除函数中。离开可排序表的元素在其.data中包含其相应的模型。因此,我们从那里检索它,并尝试将其从该集合中删除,但在随后记录该集合时,该模型从未被删除。特别奇怪的是,它上面的接收函数使用相同的精确模型来添加数据,效果非常好。有什么想法吗?我感谢你的帮助

不确定是否相关或只是在此处复制错误,但在receive中,您似乎正在将productView添加到集合中,并在remove中删除productView.model.Good spot。遗憾的是,这只是一个复制错误。我已经编辑了这篇文章。问题仍然存在……我深入到主干关系代码中,通过删除其中的一行代码,我修复了我遇到的问题。我在他们的github上提交了一个bug:很可能是我做错了什么,但希望提交一个bug会引起一些注意: