> Alright, This is really messy, but it works. If anyone's got any tips
> on cleaning it up, have at it.
>
>    if ($('body').is('#page-photography')) { //I only want it to fire
> on one page. Guessing I save some miniscule amount of overhead on the
> other pages.
>                 var loc = window.location.hash; // get the anchor from the 
> link,
> sohttp://www.example.com/index.php#testwould give me #test
>                 loc = loc.replace(/\#/g,""); // remove the pound symbol to 
> give
> me just test
>                 var j = 0; // set a variable i'll be incrementing later. i 
> have
> to do this because of some messy html later on.
>                 var goHere = 0; //set this so that, no matter what, the
> startingSlide parameter gets something
>                 
> $("#view-photos-block_1").children().children().each(function(i)
> { //i'm sure this could be cleaner. that might also be able to remove
> the j variable.
>                         if($(this).attr('id')) { //find out if there even is 
> an id
> attribute; important because this is what controls j incrementin
>                                 if($(this).attr('id') == loc) { //if the id 
> and the anchor are
> the same, set goHere. this will later be used as the startingSlide
> parameter
>                                         goHere = j;
>                                         }
>                                 j++; //increment j; this give me the real 0 
> index of the slide.
>                                 }
>                 })
>         }
>

I would think your code could be simplified down to something
resembling this:

var $slide = $(window.location.hash);
if ($slide.length) {
    // found a match on hash id
    var $slideshow = $slide.parent();
    var index = $slideshow.index($slide);

    $slideshow.cycle({
        startindIndex: index
    });
}

Reply via email to