drupal_call_js

  1. drupal
    1. 4.7
Versions
4.7 drupal_call_js($function)

Generates a Javascript call, while importing the arguments as is. PHP arrays are turned into JS objects to preserve keys. This means the array keys must conform to JS's member naming rules.

Parameters

$function The name of the function to call.

$arguments An array of arguments.

Related topics

Code

includes/common.inc, line 1273

<?php
function drupal_call_js($function) {
  $arguments = func_get_args();
  array_shift($arguments);
  $args = array();
  foreach ($arguments as $arg) {
    $args[] = drupal_to_js($arg);
  }
  $output = '<script type="text/javascript">' . $function . '(' . implode(', ', $args) . ');</script>';
  return $output;
}
?>