Themes: when initiating a search, avoid triggering a reset event when it's not necessary.

props matveb.
fixes #26434.


git-svn-id: https://develop.svn.wordpress.org/trunk@26685 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2013-12-05 19:14:59 +00:00
parent 74ea276315
commit dc7082fbc7

View File

@ -129,11 +129,10 @@ themes.Collection = Backbone.Collection.extend({
// Performs a search within the collection
// @uses RegExp
search: function( term ) {
var self = this,
match, results, haystack;
var match, results, haystack;
// Start with a full collection
self.reset( themes.data.themes );
this.reset( themes.data.themes, { silent: true } );
// The RegExp object to match
//
@ -144,7 +143,7 @@ themes.Collection = Backbone.Collection.extend({
// Find results
// _.filter and .test
results = self.filter( function( data ) {
results = this.filter( function( data ) {
haystack = _.union( data.get( 'name' ), data.get( 'description' ), data.get( 'author' ), data.get( 'tags' ) );
if ( match.test( data.get( 'author' ) ) ) {
@ -154,7 +153,7 @@ themes.Collection = Backbone.Collection.extend({
return match.test( haystack );
});
self.reset( results );
this.reset( results );
},
// Paginates the collection with a helper method