js_example_accordion

7 js_example.module js_example_accordion()
8 js_example.module js_example_accordion()

js_example_accordion implementation.

Related topics

1 string reference to 'js_example_accordion'

File

js_example/js_example.module, line 74
Examples showing how to use some of the new JavaScript features in Drupal 7.

Code

function js_example_accordion() {
  $title = t('Click sections to expand or collapse:');
  $build['myelement'] = array(
    '#theme' => 'my_accordion', 
    '#title' => $title,
  );
  $build['myelement']['#attached']['library'][] = array('system', 'ui.accordion');
  $build['myelement']['#attached']['js'][] = array(
    'data' => '(function($){$(function() { $("#accordion").accordion(); })})(jQuery);',
    'type' => 'inline',
  );
  $output = drupal_render($build);
  return $output;
}
Login or register to post comments