Skip to main content
added 174 characters in body
Source Link
Mołot
  • 21.9k
  • 8
  • 59
  • 112

I see two problems with your code:

  1. #ajax should be set on one of button, checkbox, checkboxes, image button, password, radio, radios, select, submit, tableselect, textarea, text_format, textfield. You are setting it directly on form, not on form submit element, so it cannot work.

  2. You should also set ['#ajax']['prevent'] if your form gets reloaded. In theory:

Description: A JavaScript event to prevent when 'event' is triggered. Defaults to 'click' for #ajax on #type 'submit', 'button', and 'image_button'.

In practice, it often fails to work as expected and I found it safer to set it explicitly.


In the button's array, be sure your #ajax definition is on the same level [#type] => submit is. Don't put it under #submit or any other button's sub-array.

I see two problems with your code:

  1. #ajax should be set on one of button, checkbox, checkboxes, image button, password, radio, radios, select, submit, tableselect, textarea, text_format, textfield. You are setting it directly on form, not on form submit element, so it cannot work.

  2. You should also set ['#ajax']['prevent'] if your form gets reloaded. In theory:

Description: A JavaScript event to prevent when 'event' is triggered. Defaults to 'click' for #ajax on #type 'submit', 'button', and 'image_button'.

In practice, it often fails to work as expected and I found it safer to set it explicitly.

I see two problems with your code:

  1. #ajax should be set on one of button, checkbox, checkboxes, image button, password, radio, radios, select, submit, tableselect, textarea, text_format, textfield. You are setting it directly on form, not on form submit element, so it cannot work.

  2. You should also set ['#ajax']['prevent'] if your form gets reloaded. In theory:

Description: A JavaScript event to prevent when 'event' is triggered. Defaults to 'click' for #ajax on #type 'submit', 'button', and 'image_button'.

In practice, it often fails to work as expected and I found it safer to set it explicitly.


In the button's array, be sure your #ajax definition is on the same level [#type] => submit is. Don't put it under #submit or any other button's sub-array.

Source Link
Mołot
  • 21.9k
  • 8
  • 59
  • 112

I see two problems with your code:

  1. #ajax should be set on one of button, checkbox, checkboxes, image button, password, radio, radios, select, submit, tableselect, textarea, text_format, textfield. You are setting it directly on form, not on form submit element, so it cannot work.

  2. You should also set ['#ajax']['prevent'] if your form gets reloaded. In theory:

Description: A JavaScript event to prevent when 'event' is triggered. Defaults to 'click' for #ajax on #type 'submit', 'button', and 'image_button'.

In practice, it often fails to work as expected and I found it safer to set it explicitly.