jqueryjquery-toolsjquery-scrollable

How to Deep Link with jQuery Tools' Scrollable


I am using jQuery Tools' Scrollable as the means to navigate through a whole single-page site.

Navigation looks like this:

<div id="mainNavContainer">
        <nav>
            <a id="logo" href="#home" title="Hughes Opticians, Delmar, NY"></a>
            <a href="#who-we-are" title="Who We Are">Who We Are</a>
            <a href="#eye-exams" title="Eye Exams">Eye Exams</a>
            <a href="#gallery" title="Gallery">Gallery</a>
            <a href="#eyewear" title="Eyewear">Eyewear</a>
            <a href="#contact-lenses" title="Contact Lenses">Contact Lenses</a>
            <a href="#contact" title="Contact">Contact</a>
        </nav>
</div>

jQuery to fire it looks like this:

$("#homeScrollable").scrollable({circular:true, next:'.mainNext', prev:'.mainPrev'}).navigator({navi:'#mainNavContainer nav'});

So the navigation moves horizontally to the correct page, but the hash doesn't go to the URL, nor can I link to a slide.

Basically, how can I both deeplink, but also use the nav as the plugin's navigator target?

In response to the reply below,

I tried this to test:

var hash = self.document.location.hash.substring(1) ;
    if(hash == "home"){
        console.log('Home page')
    }
    if(hash == "who-we-are"){
        console.log('Who we are page')
    }
    if(hash == "eye-exams"){
        console.log('Eye Exams page')
    }
    if(hash == "gallery"){
        console.log('Gallery page')
    }
    if(hash == "eyewear"){
        console.log('Eyewear page')
    }
    if(hash == "contact-lenses"){
        console.log('Contact Lenses page')
    }
    if(hash == "contact"){
        console.log('Contact page')
    }

Console echoes each console.log message twice. Should it not just echo my URL's current hash tag?


Solution

  • Coming back on my previous answer, I found something neat:

    unescape(self.document.location.hash.substring(1));
    

    So with this you could do something like:

    //onload
    var hash = self.document.location.hash.substring(1) ;
    if(hash != ""){
      //Run your scrollto code with the hash var
    }