Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/backbone.collectionView.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
{ "sortableOptions" : null },
{ "reuseModelViews" : true },
{ "detachedRendering" : false },
{ "emptyListCaption" : null }
{ "emptyListCaption" : null },
{ "class" : 'selected' }
],

initialize : function( options ) {
Expand Down Expand Up @@ -686,6 +687,8 @@
},

_addSelectedClassToSelectedItems : function( oldItemsIdsWithSelectedClass ) {
var options = this.getOptions();

if( _.isUndefined( oldItemsIdsWithSelectedClass ) ) oldItemsIdsWithSelectedClass = [];

// oldItemsIdsWithSelectedClass is used for optimization purposes only. If this info is supplied then we
Expand All @@ -695,21 +698,21 @@
itemsIdsFromWhichSelectedClassNeedsToBeRemoved = _.without( itemsIdsFromWhichSelectedClassNeedsToBeRemoved, this.selectedItems );

_.each( itemsIdsFromWhichSelectedClassNeedsToBeRemoved, function( thisItemId ) {
this._getContainerEl().find( "[data-model-cid=" + thisItemId + "]" ).removeClass( "selected" );
this._getContainerEl().find( "[data-model-cid=" + thisItemId + "]" ).removeClass( options.class );

if( this._isRenderedAsList() ) {
this._getContainerEl().find( "li[data-model-cid=" + thisItemId + "] > *" ).removeClass( "selected" );
this._getContainerEl().find( "li[data-model-cid=" + thisItemId + "] > *" ).removeClass( options.class );
}
}, this );

var itemsIdsFromWhichSelectedClassNeedsToBeAdded = this.selectedItems;
itemsIdsFromWhichSelectedClassNeedsToBeAdded = _.without( itemsIdsFromWhichSelectedClassNeedsToBeAdded, oldItemsIdsWithSelectedClass );

_.each( itemsIdsFromWhichSelectedClassNeedsToBeAdded, function( thisItemId ) {
this._getContainerEl().find( "[data-model-cid=" + thisItemId + "]" ).addClass( "selected" );
this._getContainerEl().find( "[data-model-cid=" + thisItemId + "]" ).addClass( options.class );

if( this._isRenderedAsList() ) {
this._getContainerEl().find( "li[data-model-cid=" + thisItemId + "] > *" ).addClass( "selected" );
this._getContainerEl().find( "li[data-model-cid=" + thisItemId + "] > *" ).addClass( options.class );
}
}, this );
},
Expand Down