views:

287

answers:

3

I've added the excellent galleria-plugin to a website I'm working on. However unlike the demo, I've been unable to make the first image display automatically on page-load.

Currently, you have to click an image, before one will appear, after that everything works as expected. And yes, I've tried setting the class of the first image to "active", but without that having any effect.

Is there anything obvious I'm missing ?

There's a live example at: http://kaciekimber.co.za/property/r8453d

+1  A: 

Try this:

$(function(){
    $('.galleria img:first').click();
});
Simeon
+1 Beat me to it.
Sohnee
Tried now (and live on the aforementioned url), but zero effect whatsoever. :-(
Agrajag
You must insert the statement on DOM Ready. I've edited my answer.
Simeon
Uhm, I did.I put it last in my -existing- on document.ready function. Unless I'm even less sane than I thought :-/
Agrajag
It seem to be working now?
Simeon
Sorry, I was wrong. Where on the page, or in which JS file, is this included?
Simeon
Line 78. I even added it for "gallery" too, since I've used that as the class for the ul, not "galleria", but neither made any difference.(nor did replacing the complex galleria-invocation with the trivial one on line 56) Thanks a lot for taking the time for looking into this, I appreciate it !
Agrajag
I've just been trying to work this out myself, and the problem with this (I think) is that it first requires the DOM changes that Galleria makes to be done. Therefore, putting this inside the `.ready` doesn't work, but calling it later (say, with Firebug) does. However, the other solution (`<li class="active">`) works perfectly. Thanks.
David Johnstone
+2  A: 

I think I've found the problem. Add <li class="active"> instead of <img class="active" ... /> and your first image will load automatically.

Simeon
/facepalm. That was kinda embarassing. I don't entirely get why the .click() method didn't work though, but this works, as it should. Thanks a lot !
Agrajag
@Agrajag the `.click()` method doesn't work because the DOM for Galleria isn't completely loaded when `.click()` is called. If you call the `.click()` method slightly later (say, with Firebug) it works as you would expect. I know this because I've been struggling with this exact question over the past couple of days :-)
David Johnstone
A: 

Yeh its a cool gallery I am using it as well :

http://www.achlandscapes.co.uk/decking.htm

Essex Landscaper