0

I need to add a button to an exposed views form that is available for logged-in users. This button should perform some actions via AJAX when clicked. The form has AJAX enabled.

I used the following hook_form_alter function:

$form['custom-ajax'] = array(
        '#type' => 'button',
        '#value' => 'test',
        '#value' => 'Do Something',
        '#submit' => array('submit_array_2'),
        '#ajax' => array(
          'callback' => 'my_module_do_something',
          'event' => 'mouseup',
          'wrapper' => 'wrapper',
        )
      );

It renders the button correctly but a couple things happen. The AJAX throbber for the views starts spinning on page load and doesn't stop and when the added button is clicked I get a 404 with a path targeting /views/ajax.

I've tried to change the url attribute of the AJAX call but haven't had any luck.

What am I doing wrong?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.