Skip to content

Commit b8618b3

Browse files
author
gmac
committed
Optimizing collection binding bug fix, updating version and builds.
1 parent 28ba351 commit b8618b3

4 files changed

+9
-9
lines changed

backbone.epoxy.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -596,20 +596,20 @@
596596
// Add new view:
597597
views[ target.cid ] = view = new collection.view({model: target});
598598
var index = _.indexOf(models, target);
599+
var $children = $element.children();
599600

600601
// Attempt to add at proper index,
601602
// otherwise just append into the element.
602-
if ($element.children().length > index) {
603-
$element.children().eq(index).before(view.$el);
603+
if (index < $children.length) {
604+
$children.eq(index).before(view.$el);
604605
} else {
605606
$element.append(view.$el);
606607
}
607608

608609
} else {
609610

610611
// Remove existing view:
611-
view = views[ target.cid ];
612-
view.remove();
612+
views[ target.cid ].remove();
613613
delete views[ target.cid ];
614614
}
615615

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

0 commit comments

Comments
 (0)