WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer
Arg. so obvious. Thanks man. The link to the JS script is particularly useful. I didn't know where to look. Thanks! – Tom Auger May 28 '11 at 16:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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