Skip to content

Commit

Permalink
added index that takes into consideration 'options' being undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
boxxxie committed Oct 4, 2012
1 parent 5239b12 commit 224768c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
10 changes: 9 additions & 1 deletion lib/amd/backbone.marionette.js
Expand Up @@ -318,7 +318,15 @@
addChildView: function(item, collection, options){
this.closeEmptyView();
var ItemView = this.getItemView(item);
return this.addItemView(item, ItemView, options.index);
var index = (function get_index(options){
if(options && options.index){
return options.index;
}
else{
return 0;
}
})(options);
return this.addItemView(item, ItemView, index);
},

// Override from `Marionette.View` to guarantee the `onShow` method
Expand Down
2 changes: 1 addition & 1 deletion lib/amd/backbone.marionette.min.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion lib/backbone.marionette.js
Expand Up @@ -302,7 +302,15 @@ Marionette.CollectionView = Marionette.View.extend({
addChildView: function(item, collection, options){
this.closeEmptyView();
var ItemView = this.getItemView(item);
return this.addItemView(item, ItemView, options.index);
var index = (function get_index(options){
if(options && options.index){
return options.index;
}
else{
return 0;
}
})(options);
return this.addItemView(item, ItemView, index);
},

// Override from `Marionette.View` to guarantee the `onShow` method
Expand Down
2 changes: 1 addition & 1 deletion lib/backbone.marionette.min.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion src/backbone.marionette.collectionview.js
Expand Up @@ -26,7 +26,15 @@ Marionette.CollectionView = Marionette.View.extend({
addChildView: function(item, collection, options){
this.closeEmptyView();
var ItemView = this.getItemView(item);
return this.addItemView(item, ItemView, options.index);
var index = (function get_index(options){
if(options && options.index){
return options.index;
}
else{
return 0;
}
})(options);
return this.addItemView(item, ItemView, index);
},

// Override from `Marionette.View` to guarantee the `onShow` method
Expand Down

0 comments on commit 224768c

Please sign in to comment.