Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

up vote 2 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

 
discard

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.