You are here

function js_example_accordion in Examples for Developers 7

Demonstrate accordion effect.

Related topics

1 string reference to 'js_example_accordion'
js_example_menu in js_example/js_example.module
Implements hook_menu().

File

js_example/js_example.module, line 112
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;
}