2

I want to be able by default have a dropdown block expanded instead of the current default which is to show just the link and if the user clicks on it then it would expand. Below is some code related to collapsing and expanding dropdown blocks which is contained within a .js file within the default theme (sites/all/themes/fusion/mapsindeed/js). How would I, by default, have a dropdown block expanded instead of collapsed?

//ability to expand and collapse dropdown blocks
Drupal.behaviors.mapsindeedDropdownBlock = function (context) {
$('.mapsindeed-dropdown-block .content').hide();
  $('.mapsindeed-dropdown-block h2.block-title').bind('click', function(){
  $(this).siblings('.content').slideToggle('slow', function() {    
     });
   $(this).parents('.mapsindeed-dropdown-block').toggleClass('expanded');   
});
}

2 Answers 2

0

Remove $('.mapsindeed-dropdown-block .content').hide(); from the above, and replace it with the following code:

$('.mapsindeed-dropdown-block .content').addClass('expanded');
1
  • It did not work when I removed and replaced using the Answer suggestion (See revised code below) //ability to expand and collapse dropdown blocks Drupal.behaviors.mapsindeedDropdownBlock = function (context) { $('.mapsindeed-dropdown-block .content').addClass('expanded'); $('.mapsindeed-dropdown-block h2.block-title').bind('click', function(){ $(this).siblings('.content').slideToggle('slow', function() { }); $(this).parents('.mapsindeed-dropdown-block').toggleClass('expanded'); }); } Jan 12, 2012 at 15:02
0

I have fixed the issue by doing the following:

  • Remove $('.mapsindeed-dropdown-block .content').hide();
  • Replace it with $('.mapsindeed-dropdown-block .content').show();

Your Answer

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

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