views:

12

answers:

1

I am referring to the portlet example here

All the divs of the class 'portlet-content' are displayed when the demo starts. I am trying to get them to collapse when the page loads, and I tried this:

$('.portlet-content').toggle();

Inside the document.ready(). However this doesn't work.

However, if I enter the statement above using the Firebug console, it does work. Do I need to override some default event?

Edit: It seems that the toggle works; however, when the tab is selected, it seems that all the div inside it are also toggled. Is there anyway to prevent this behaviour?

A: 

Perhaps, you should try with another event:

$(window).load(function()
{
$('.portlet-content').toggle();
});

In the demo js, it must exist something executing after the dom is loaded ($(document).ready)

netadictos
This does work. However, the div will automatically be toggled when a tab is clicked.
Extrakun
You can manage this with variables surely. I don't see that clearly for your explanation.
netadictos