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:
parent
74ea276315
commit
dc7082fbc7
@ -129,11 +129,10 @@ themes.Collection = Backbone.Collection.extend({
|
|||||||
// Performs a search within the collection
|
// Performs a search within the collection
|
||||||
// @uses RegExp
|
// @uses RegExp
|
||||||
search: function( term ) {
|
search: function( term ) {
|
||||||
var self = this,
|
var match, results, haystack;
|
||||||
match, results, haystack;
|
|
||||||
|
|
||||||
// Start with a full collection
|
// Start with a full collection
|
||||||
self.reset( themes.data.themes );
|
this.reset( themes.data.themes, { silent: true } );
|
||||||
|
|
||||||
// The RegExp object to match
|
// The RegExp object to match
|
||||||
//
|
//
|
||||||
@ -144,7 +143,7 @@ themes.Collection = Backbone.Collection.extend({
|
|||||||
|
|
||||||
// Find results
|
// Find results
|
||||||
// _.filter and .test
|
// _.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' ) );
|
haystack = _.union( data.get( 'name' ), data.get( 'description' ), data.get( 'author' ), data.get( 'tags' ) );
|
||||||
|
|
||||||
if ( match.test( data.get( 'author' ) ) ) {
|
if ( match.test( data.get( 'author' ) ) ) {
|
||||||
@ -154,7 +153,7 @@ themes.Collection = Backbone.Collection.extend({
|
|||||||
return match.test( haystack );
|
return match.test( haystack );
|
||||||
});
|
});
|
||||||
|
|
||||||
self.reset( results );
|
this.reset( results );
|
||||||
},
|
},
|
||||||
|
|
||||||
// Paginates the collection with a helper method
|
// Paginates the collection with a helper method
|
||||||
|
Loading…
Reference in New Issue
Block a user