Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add getSubviewFromElement, getSubviewFromModel.

  • Loading branch information...
commit 245ab8b682724e0335371bf2274ce51c4c839ee1 1 parent a90edf7
Alexander Staubo authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 jquery_collection_view.js
View
10 jquery_collection_view.js
@@ -53,6 +53,14 @@ Backbone.JQuery.CollectionView = Backbone.View.extend({
throw "Not implemented";
},
+ getSubviewFromElement: function(element) {
+ return _(this._subviews).select(function(v) { return v.el === element; })[0];
+ },
+
+ getSubviewFromModel: function(model) {
+ return _(this._subviews).select(function(v) { return v.model === model; })[0];
+ },
+
_setupSubviewElement: function(view) {
var el = view.render().el;
if (this.draggingEnabled) {
@@ -85,7 +93,7 @@ Backbone.JQuery.CollectionView = Backbone.View.extend({
},
_remove: function(model) {
- var view = _(this._subviews).select(function(v) { return v.model === model; })[0];
+ var view = this.getSubviewFromModel(model);
if (view) {
this._subviews = _(this._subviews).without(view);
if (this._rendered) {
Please sign in to comment.
Something went wrong with that request. Please try again.