the jqueryui accordion it only takes the first item from the list. I copy into my theme views-view-field--field-summary.tpl.php file and add this code

    <meta charset="utf-8" />
  <!--<title>jQuery UI Accordion - Collapse content</title>-->
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  <?php print '<script src="http://code.jquery.com/jquery-1.9.1.js"></script>';?>
  <?php print '<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>';?>
  <link rel="stylesheet" href="/resources/demos/style.css" />

<?php print '<div id="accordion">';?>
     <?php print '<h3>Show summary</h3>'; ?>
         <?php print '<div>'; ?>
           <?php print '<p>'; ?>
             <?php print $output; ?>
           <?php print '</p>'; ?> 
        <?php print '</div>'; ?>
   <?php print '</div>'; ?>

   <?php print '<script>
  $(function() {

$( "#accordion" ).accordion({ header: "h3", collapsible: true, active: false });

The output is what you show in the picture.example Why remaining elements take no accordion effect?

  • 1
    There is already module drupal.org/project/views_accordion to integrate accordion with views. Commented Oct 15, 2013 at 6:43
  • I do not want to use views_accordion, I do it this way.
    – Jansel
    Commented Oct 15, 2013 at 12:08
  • Then you need to embed your javascript in code (function($) { [accordion code] })(jQuery); Commented Oct 15, 2013 at 12:25


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.