Skip to content

Commit

Permalink
Optimizing collection binding bug fix, updating version and builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmac committed Jul 11, 2013
1 parent 28ba351 commit b8618b3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions backbone.epoxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,20 +596,20 @@
// Add new view:
views[ target.cid ] = view = new collection.view({model: target});
var index = _.indexOf(models, target);
var $children = $element.children();

// Attempt to add at proper index,
// otherwise just append into the element.
if ($element.children().length > index) {
$element.children().eq(index).before(view.$el);
if (index < $children.length) {
$children.eq(index).before(view.$el);
} else {
$element.append(view.$el);
}

} else {

// Remove existing view:
view = views[ target.cid ];
view.remove();
views[ target.cid ].remove();
delete views[ target.cid ];
}

Expand All @@ -618,7 +618,7 @@
// SORT/RESET Event (from a Collection):
// First test if we're sorting...
// (we have models and all their views are present)
var sort = models.length && _.every(models, function(model) {
var sort = models.length && collection.every(function(model) {
return views.hasOwnProperty(model.cid);
});

Expand Down
Loading

0 comments on commit b8618b3

Please sign in to comment.