Is it possible to create a callback for tb_show?

I use tb_show() in my wordpress editor after clicking my custom shortcode button.

tb_show(“My Shortcodes”, “my-custom-panel.html”);

Read More

where tb_show is out of my control.

How can I bind events for a button within my-custom-panel.html after the page loads?

I have a restriction that I can’t put the javascript within “my-custom-panel.html”.

Thanks

Related posts

Leave a Reply

1 comment

  1. You may use a delegated handler for the button that is within your my-custom-panel.html even if it’s not loaded yet in the DOM, for example:

    $(document).on('click', 'your-element-id-class', function() {
        //...
    });
    

    If you load the content dynamically after DOM has loaded then still this will work. I’ve used click event for the example tho.