I'm using Thickbox (lightbox) built-in in WordPress to display some controls for user, some of controls using javascript to open dialogs like Upload Media that is already works fine outside the Thickbox.

I know that the Thickbox creates a new div with a unique-ID [TB_window] so i made a stand-alone js file for all scripts in Thickbox only but it still not working, it may be because Thickbox takes all controls from hidden container div and put it inside popup but i cannot deal with this scenario.

Any ideas? Thanks!

1 Answer 1


Finally, I found the solution by replacing event handler!

Old Scenario (WRONG)

$('#TB_window').on('click', '.upload_media a.btn_media_upload', function (e) { //Code } );

New (Working)

$('body').on('click', '#TB_window .upload_media a.btn_media_upload', function (e) { // Code });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.