Skip to content

Instantly share code, notes, and snippets.

@m7v
Created March 28, 2014 00:55
Show Gist options
  • Save m7v/9822696 to your computer and use it in GitHub Desktop.
Save m7v/9822696 to your computer and use it in GitHub Desktop.
Hook_js (provided module JS)
/**
* Implements hook_js().
*/
function spaint_cache_js() {
$items = array();
require_once DRUPAL_ROOT . '/includes/path.inc';
$items['user_data'] = array(
'callback' => 'user_data',
'bootstrap' => DRUPAL_BOOTSTRAP_SESSION,
'page arguments' => array(1, 2, 3),
);
return $items;
}
//If you need to call js-callback use AJAX and next URL-scheme
// js/{module}/{callback}/{page_arguments}
$.ajax({
type: 'GET',
url: '/js/spaint_cache/user_data/' + language + '/' + uid + '/' + nid,
success: function (data) {
Spaint.attachActualData(data, uid, context, settings);
iambusy.stop();
},
dataType: 'json'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment