Make WordPress Core

Changeset 29073


Ignore:
Timestamp:
07/10/2014 06:24:23 PM (12 years ago)
Author:
wonderboymusic
Message:

Media Grid: make the router work when ?item= is in the URL on page load. This is still a hack, needs to be event-driven.
See #24716.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/media-grid.js

    r29072 r29073  
    141141                        this.render();
    142142
    143                         this.gridRouter = new media.view.Frame.Router( this );
    144 
    145                         // Set up the Backbone router after a brief delay
    146                         _.delay( function(){
    147                                 // Verify pushState support and activate
    148                                 if ( window.history && window.history.pushState ) {
    149                                         Backbone.history.start({
    150                                                 root: mediaGridSettings.adminUrl,
    151                                                 pushState: true
    152                                         });
    153                                 }
    154                         }, 250);
    155 
    156143                        // Update the URL when entering search string (at most once per second)
    157144                        $( '#media-search-input' ).on( 'input', _.debounce( function(e) {
     
    162149                                self.gridRouter.navigate( self.gridRouter.baseUrl( url ) );
    163150                        }, 1000 ) );
     151
     152                        _.delay( _.bind( this.createRouter, this ), 1000 );
     153                },
     154
     155                createRouter: function() {
     156                        this.gridRouter = new media.view.Frame.Router( this );
     157
     158                        // Verify pushState support and activate
     159                        if ( window.history && window.history.pushState ) {
     160                                Backbone.history.start({
     161                                        root: mediaGridSettings.adminUrl,
     162                                        pushState: true
     163                                });
     164                        }
    164165                },
    165166
Note: See TracChangeset for help on using the changeset viewer.