Skip to content

Instantly share code, notes, and snippets.

@martsie
Created January 25, 2017 11:05
Show Gist options
  • Save martsie/9b0ad580db32ec4915c6d0031600ecea to your computer and use it in GitHub Desktop.
Save martsie/9b0ad580db32ec4915c6d0031600ecea to your computer and use it in GitHub Desktop.
Trigger page callback for AJAX commands article
<?php
function MY_CUSTOM_MODULE_trigger_page() {
// Load in Drupal core AJAX library.
drupal_add_library('system', 'drupal.ajax');
// Load in our custom JavaScript.
drupal_add_js(drupal_get_path('module', 'MY_CUSTOM_MODULE') . '/MY_CUSTOM_MODULE.js');
// Present the user with a link with the id 'my-special-link'.
return l('Run my AJAX commands', 'my-custom-path/nojs', array(
'attributes' => array(
'id' => 'my-special-link'
)
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment