Last active
November 13, 2024 15:44
-
-
Save miteshmap/517fe9122b5e353807e4 to your computer and use it in GitHub Desktop.
Drupal - Execute custom code on ajax success call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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