Skip to content

Instantly share code, notes, and snippets.

@jduhls
Last active October 28, 2017 15:37
Show Gist options
  • Save jduhls/fc3d220cdf0c7ce3ca4a to your computer and use it in GitHub Desktop.
Save jduhls/fc3d220cdf0c7ce3ca4a to your computer and use it in GitHub Desktop.
(function($, Drupal){
// Our function name is prototyped as part of the Drupal.ajax namespace, adding to the commands:
Drupal.ajax.prototype.commands.custom_javascript_function = function(ajax, response, status) {
// The value we passed in our Ajax callback function will be available inside the
// response object. Since we defined it as selectedValue in our callback, it will be
// available in response.selectedValue. Usually we would not use an alert() function
// as we could use ajax_command_alert() to do it without having to define a custom
// ajax command, but for the purpose of demonstration, we will use an alert() function
// here:
};
}(jQuery, Drupal));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment