1 js_example.module js_example_accordion()

Demonstrate accordion effect.

Related topics

File

modules/examples/js_example/js_example.module, line 112
Examples showing how to use some of the JavaScript features in Backdrop.

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 = backdrop_render($build);
  return $output;
}