views:

471

answers:

4

Is it possible to expand all components when page is load or when an event occurs? Thanks!!

A: 

You can do it in the document.ready event jQuery provides, like this:

CSS:

.myClassToBeHidden { display: none; }

jQuery:

$(function() {
  $(".myClassToBeHidden").slideDown();
});

If you mean with the accordion control from jQuery UI then...you shouldn't use accordion, expanding all isn't what it's for and they advise against this as it causes other issues.

Nick Craver
@durilai - Not sure what they're asking based on the question, was just adding some more info around each.
Nick Craver
@Nick - agree. I saw your update and removed comment.
Dustin Laine
+1  A: 

No, if you are referring to accordion as your tag states. From jQuery.

NOTE: If you want multiple sections open at once, don't use an accordion

http://docs.jquery.com/UI/API/1.8/Accordion

Dustin Laine
A: 

To make it unobtrusive and be hidden only if the visitor has javascript I'd put

CSS:

#divToBeHidden { display: block; }

In <head>:

$('#divToBeHidden').hide();

Bottom of <body>:

$(function() {
 $("#divToBeHidden").show(); //Or whatever means you'd prefer of showing the content
});
David Andersson
@elcherino: I don't know if I correctly understood your question, please evolve further what you'd like to do.
David Andersson
@David - You can place a `$(function() { });` function wherever you like...it won't run until the document's ready and won't block the page in either case :)
Nick Craver
@Nick Craver: Oh yeah, of course, you're right. Thanks. It's just me that likes to keep all run-time stuff in the bottom. :)
David Andersson
@David: My problem is: I have a js. My js search text into my page. But my script doesn't find text (even if is present) into hidden div.So, my idea is: when the user write a string in my input type text automatically I expand all divs so my search script run and user finds the text.Sorry for my bad english :-)
A: 

This is a good workaround: http://paste.pocoo.org/show/105888/