Update: I should point out that I tested the method below on Plugin/theme options page and it worked perfectly. In-fact I was also able to include the jQuery cookie Plugin to preserve the current tab selection between page loads (nice!).
Been trying to add tabs to an admin widget to reduce the form footprint when you have multiple widget options. I am using the jQuery UI tabs included with WordPress. Here’s what I have so far coded into a Plugin.
When the widget is dragged into a widget area the tabs seem to render OK but you can’t click to view the second tab. Worse still if you refresh the widgets page the formatting of the tabs is completely lost, and the tabs still don’t respond to click events.
Not sure what the problem is here. Any help appreciated.
The problem is that you’re not using unique IDs (#tabs, #tabs-1 …), because widgets have multiple instances (the same IDs are used by the instance form the “Available Widgets” area).
So just prepend or append the widget instance ID to your identifiers to make them unique:
Also, not sure if WP 3.3 fixed this issue, but after the first drag inside the sidebar, the widget-save action needs to be manually triggered for the
id
property to become available inside the form() function.