views:

51

answers:

3

Hi,

I'm using the jQuery GalleryView plugin. I've use the plugin on one page and contained it in a div with the appropriate code which sends the div's id to the external GalleryView .js file.

I'm also using jQuery to hide the div on document ready, so the users can toggle the visibility, but for some reason when the div is hidden innitially, the gallery does not load correctly. I believe this may be because the script inside the code is not being called due to it's hidden status.

I hope I have explained this clearly enough. Does anyone have any ideas?

The plugin home page can be found here or I believ the jQuery page is more up to date but not as well documented.

+1  A: 
Gaby
How would I hide them only when the gallery has initialized?
Jack Roscoe
assuming your run something like this `$('#id').galleryView({...});` chain the hide to it like this `$('#id').galleryView({...}).hide();`. If you can point me to the page of the plugin you use i could be more specific..
Gaby
Thanks for the help. I've updated the question with a link to the plugin's home page.
Jack Roscoe
@Jack, did chaining the `.hide()` code work ?
Gaby
@Gaby Previously the gallery was getting stuck on the loading bar. If I chain the .hide() like you said, it loads the first image of the gallery, but the rest of the javascript seems to feel and it loads no menu. Not sure why.
Jack Roscoe
@jack, updated my answer with some more understanding of what is going on..
Gaby
Gaby, yes that works perfectly! Thank you so much for the help, you've saved me much trouble.
Jack Roscoe
A: 

http://docs.jquery.com/Plugins/livequery

NimChimpsky
This functionality supported by jquery core since 1.4 - .live() method.
fantactuka
A: 

The problem is that js does not "see" the content of elements with display: none;

The easiest solution: use position hiding instead of display: none;

Html:

<div class="hidden">...</div>

Css:

.hidden {
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
}

And in js .addClass('hidden') and .removeClass('hidden') to hide or show the element

In this case this element will be "visible" for js and images to load, but hidden from user.

fantactuka