David O'Sullivan
David O'Sullivan

Reputation: 2999

How to bind to load completion of new Wordpress 3.5 Media Manager

I need to modify the output of the new Wordpress 3.5 Media Manager after it has loaded all of the items to browse in the library and gallery views but I cannot for the life of me find an event that I can bind to...

Does anybody know if there is something like a 'wpMediaEditorLoaded' event triggered when all the images have been loaded or something similar that I could use?

Upvotes: 0

Views: 171

Answers (1)

David O'Sullivan
David O'Sullivan

Reputation: 2999

I found I could use this

wp.media.view.Attachments.prototype.on('ready',function(){
    //this runs once for each tab in the media editor so unbind previous versions
        jQuery(document).unbind('ajaxComplete', mediaLibraryLoaded);
        jQuery(document).bind('ajaxComplete', mediaLibraryLoaded);
      });
var mediaLibraryLoaded = function(e, xhr, options) {        
         jQuery(document).unbind('ajaxComplete', mediaLibraryLoaded);
        //do stuff here
       }

Upvotes: 0

Related Questions