Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Date: Thu, 20 Dec 2012 16:28:50 -0500
From: Daryl Koopersmith <>
Subject: Re: [wp-hackers] Javascript bind event for 3.5's new
Message-ID: <>
Content-Type: text/plain; charset="utf-8"
> I'm trying to add an action when the uploader is displayed, but I
> can't seem to call the .on or .bind from external code.
> Unfortunately, it seems this can't be added from external code.
>,, and others will not work.
Hi Luke, is used to manage instances of editor-specific media managers. If you're looking to trigger an event when opening the default media modal, you'll want to grab a reference to the media manager by calling'content'). We're calling "add" here instead of "get" to make sure the modal exists, because "get" may return undefined (and don't worry, "add" only creates the instance once). You can then call the .on method on that object and your code will run just fine.
For example:
var media ='content');
media.on( 'open', function() {
console.log( 'Opening the modal?' );
Hope this helps.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment