hash in url to deep linking with ajax -


i've code load content in div #target animation. works fine don't know how implement code change link , url #hash! how can this?

the code:

$(document).ready(function(){   $("#target").addclass('hide');    $('.ajaxtrigger').click(function() {        var pagina = $(this).attr('href');     if ($('#target').is(':visible')) {      }     $("#target").removeclass('animated show page fadeinrightbig').load(pagina,        function() {          $("#target").delay(10).transition({ opacity: 1 })           .addclass('animated show page fadeinrightbig');                               }     );     return false;    }); }); 

try use javascript router. example, router.js.

modify code this(i didn't check if code work, think idea should clear):

$(document).ready(function(){   var router = new router();    //define route link   router.route('/loadpath/:href', function(href) {      console.log(href);     if ($('#target').is(':visible')) {       $("#target").removeclass('animated show page fadeinrightbig').load(href,          function() {            $("#target").delay(10).transition({ opacity: 1 })             .addclass('animated show page fadeinrightbig');                                 }       );     }   });    router.route('', function(){ console.log("default route")});     $("#target").addclass('hide');    // instead of loading content in click handler,    // go url href attribute our custom prefix ('/loadpath/').   // router rest of job us. trigger event when url hash           // changes , call our handler, load contents    // appropriate url.   $('.ajaxtrigger').click(function() {     router.navigate('/loadpath/' + $(this).attr('href'));        return false;    }); }); 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -