Make WordPress Core

Changeset 36580


Ignore:
Timestamp:
02/18/2016 09:20:33 PM (11 years ago)
Author:
ocean90
Message:

Themes: After [36546] restore theme search functionality.

  • Correct several incorrect uses of _.union. Since Underscore 1.7.0 _.union supports only arrays and not variadic args.
  • Use a namespaced event themes:update. Backbone 1.2 added a built in update event that triggers after any amount of models are added or removed from a collection.

Props adamsilverstein.
See #34350.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/theme.js

    r36270 r36580  
    159159                }
    160160
    161                 // Trigger an 'update' event
    162                 this.trigger( 'update' );
     161                // Trigger a 'themes:update' event
     162                this.trigger( 'themes:update' );
    163163        },
    164164
     
    186186                        author      = data.get( 'author' ).replace( /(<([^>]+)>)/ig, '' );
    187187
    188                         haystack = _.union( name, data.get( 'id' ), description, author, data.get( 'tags' ) );
     188                        haystack = _.union( [ name, data.get( 'id' ), description, author, data.get( 'tags' ) ] );
    189189
    190190                        if ( match.test( data.get( 'author' ) ) && term.length > 2 ) {
     
    265265                                // Trigger a collection refresh event
    266266                                // and a `query:success` event with a `count` argument.
    267                                 self.trigger( 'update' );
     267                                self.trigger( 'themes:update' );
    268268                                self.trigger( 'query:success', count );
    269269
     
    309309                        }
    310310
    311                         this.trigger( 'update' );
     311                        this.trigger( 'themes:update' );
    312312                        this.trigger( 'query:success', this.count );
    313313                }
     
    864864
    865865                // When the collection is updated by user input...
    866                 this.listenTo( self.collection, 'update', function() {
     866                this.listenTo( self.collection, 'themes:update', function() {
    867867                        self.parent.page = 0;
    868868                        self.currentTheme();
    869869                        self.render( this );
    870                 });
     870                } );
    871871
    872872                // Update theme count to full result set when available.
     
    14791479                // Construct the filter request
    14801480                // using the default values
    1481                 filter = _.union( filter, this.filtersChecked() );
     1481                filter = _.union( [ filter, this.filtersChecked() ] );
    14821482                request = { tag: [ filter ] };
    14831483
Note: See TracChangeset for help on using the changeset viewer.