My custom widget's form will have two pull-down menus: the content of the second menu is dependent on the user's selection in the first menu (think of the way Country and State/Province works).

I think the easiest implementation (though perhaps not the most user-friendly) would simply be to have the form automatically submit itself when the first pulldown is changed (ie: <select onchange="submit_the_page_via_ajax()">). I tried onchange="this.form.submit();" but that didn't leverage the Ajax call to my surprise (I would have thought that the sophisticated WordPress developers would have hiJaxed the form's submit event). They must be hijaxing the submit button however, since all my view source shows me is a standard html input type for the button.

Anyway, I would appreciate a little insight into a best practice for submitting a widget's form leveraging ajax. This is a great post but only addresses the widget's display, not the back-end form.

1 Answer 1


The Save buttons have a class widget-control-save, and this is hooked up to wpWidgets.save(). So you either have to call wpWidgets.save(), or (probably easier) trigger a click event on the Save button.

  • Arg. so obvious. Thanks man. The link to the JS script is particularly useful. I didn't know where to look. Thanks!
    – Tom Auger
    Commented May 28, 2011 at 16:10

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.