i have search but nothing came up to solve the problem i’m having, at least none that i read and i read a lot. 🙂 my problem is that when someone goes to a url with a hash (ex: mysite.com/gallery/#image-name-1) i can make the class for it “current” so it shows as the clicked image but i can’t trigger the click function so that it will show the full size gallery image and information. my page is setup like with a big gallery image (pulls onclick and needs to pull by just the hash) and under it is a grid of thumbnails to click.
all help is appreciated. thanks in advance!!!
function gallery_grid()
{
var gallery_url = document.location.toString();
if(gallery_url.match('#'))
{
var gallery_anchor = '#' + gallery_url.split('#')[1];
$('ul.gallery-grid li a[href="' + gallery_anchor + '"]').addClass('current');
$('ul.gallery-grid li a[href="' + gallery_anchor + '"]').trigger('click'); /* need this to trigger the click function so i can pull info from it for the bigger gallery image */
}
else
{
$('ul.gallery-grid li:first a').addClass('current');
}
$('ul.gallery-grid li a').click(function()
{
// stuff goes here to grab from $(this) but it can't cause it's not triggered
});
}
It looks like you’re trying to trigger the
clickbefore you’ve added theclickhandler to the element. Move theifstatement underneath theclickhandler.