Run JS after widget settings are saved?

Question

I’ve written a small widget that uses JS for setting up some tabs in the settings panel. Is there a way to re-trigger the tab JS when the widget is done saving?

Looking at the WP JS source it doesn’t look like it, as it simply blows away the existing HTML & re-renders the entire form. I could potentially overwrite wpWidgets.save & do something nutty there but that seems really drastic.

Solution

After some hacking based upon One Trick Pony’s idea, here’s what I ended up with.

<script>
jQuery(document).ready(function($){
    if(parseInt("<?php echo $this->number; ?>", 10)) {
        $("[id$='<?php echo $this->id; ?>'] .tabs").tabs();
    }
});
</script>

Basically I just send down some JS w/ some Widgets values hardcoded in & do some checks & fun CSS3 selectors to find the right DOM nodes.

0
Tivac 2 months 0 Answers 9 views 0

Leave an answer