I'm trying to add the AJAX throbber in core to a form submit button, specifically the Private Message module new message page.
Here is my code:
function MYMODULE_form_privatemsg_new_alter(&$form, &$form_state, $form_id) {
$form['actions']['submit']['#ajax'] = array(
'callback' => 'MYMODULE_submit_throbber_callback',
);
}
function MYMODULE_submit_throbber_callback($form, $form_state) {
return;
}
Here's what I have done so far.
First, I looked at the Page Throbber module for ideas, but this does everything in hook_init()
, and it doesn't use the throbber included in core. If possible, I want to avoid replicating what is already in core for a single form.
Next, I looked in the Examples module, specifically the AJAX example that includes an AJAX submit example. However, this is for adding a callback to do something else, but all I want to do is get the pager, which appears to happen automatically if you add any kind of callback.
So I added a dummy callback that just returns. This gives me a throbber, but it breaks the submit functionality of the form. How do I get the throbber without breaking the form submit?