Skip to content

Instantly share code, notes, and snippets.

@miteshmap
Last active November 13, 2024 15:44
Show Gist options
  • Save miteshmap/517fe9122b5e353807e4 to your computer and use it in GitHub Desktop.
Save miteshmap/517fe9122b5e353807e4 to your computer and use it in GitHub Desktop.
Drupal - Execute custom code on ajax success call
(function ($) {
Drupal.fooModule = Drupal.fooModule || {};
Drupal.fooModule.success = function (response, status) {
// do some cusotm coding if needed.
// Call original method with main functionality.
Drupal.ajax.prototype.success.call(this, response, status);
};
Drupal.behaviors.fooModule = {
attach: function (context, settings) {
// custom button id "maplight-coord-submit"
// Can be added with $form['element_name']['#id'] = 'maplight-coord-submit';
Drupal.ajax['maplight-coord-submit'].success = Drupal.fooModule.success;
}
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment