2

I am trying to create a collapsible fieldset of filter criteria on click of a link the code I tried is as follows: '; ?>

<fieldset class="collapsible collapsed">
<legend class="collapse-processed">
<a href="#">Error : Uncaught TypeError: Object [object Object] has no method 'drupalGetSummary' jquery.min.js:16</a>
<a href="#">Edit Search Criteria</a>
</legend>
<fieldset>

But when I click on the link I dont get the collapsed or collapsible feature

The error I am getting is as follows: Error : Uncaught TypeError: Object [object Object] has no method 'drupalGetSummary' jquery.min.js:16
In the resources of the page the collapse.js is present which indicates that the js file is loaded.
After updating the jquery version from 1.5 to 1.7 the old error disappears and new error is displayed as follows:
Uncaught TypeError: Object [object Object] has no method 'drupalGetSummary' collapse.js:70

2
  • updated the answer pls check
    – harshal
    Commented Dec 24, 2013 at 7:07
  • as far as I remember misc/collapse.js is the js that drupal uses for collapsible fieldset, check if you are getting any js error.
    – arpitr
    Commented Dec 24, 2013 at 7:10

2 Answers 2

1

I got the above working by writing a function in the module as shown in the link

/**
 * Implements hook_preprocess_views_view().
 */
function my_module_preprocess_views_view(&$vars) {
  if ($vars['view']->name === 'my_view') {
    // Wrap exposed filters in a fieldset.
    if ($vars['exposed']) {
      drupal_add_js('misc/form.js');
      drupal_add_js('misc/collapse.js');
      // Default collapsed
      $collapsed = TRUE;
      $class = array('collapsible', 'collapsed');
      if (count($_GET) > 1){
        // assume other get vars are exposed filters, so expand fieldset
        // to show applied filters
        $collapsed = FALSE;

    $class = array('collapsible');
  }
  $fieldset['element'] = array(
    '#title' => 'Refine your search',
    '#collapsible' => TRUE,
    '#collapsed' => $collapsed,
    '#attributes' => array('class' => $class),
    '#children' => $vars['exposed'],
  );
  $vars['exposed'] = theme('fieldset', $fieldset);
}
  }
}
1
  • correct me if i am wrong but it will work only when ajax is disabled in views.
    – Ali Nouman
    Commented Dec 24, 2013 at 16:39
0

This happened often because collapse js files not loaded there,mybe by adding the js library it get work

Try this

drupal_add_js('misc/form.js');
drupal_add_js('misc/collapse.js');

or

drupal_add_library('system', 'drupal.collapse');
7
  • i have added (misc/collapse.js'); but still it does not works
    – harshal
    Commented Dec 24, 2013 at 6:53
  • pls help should i add drupal.collapse?
    – harshal
    Commented Dec 24, 2013 at 6:54
  • first look up collapse.js in loaded script in browser source, if it is not loaded try to load it with form.js. they need to collapse work
    – Yuseferi
    Commented Dec 24, 2013 at 7:10
  • Error : Uncaught TypeError: Object [object Object] has no method 'drupalGetSummary' jquery.min.js:16
    – harshal
    Commented Dec 24, 2013 at 7:21
  • as you know jquery error sometimes disrupt js jobs.maybe it be the source of problem,update your jquery,do you install jquery update module? if yes go to settings of it and try another versions
    – Yuseferi
    Commented Dec 24, 2013 at 7:25

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.