views:

32

answers:

1

Live demo here <- http://webcallonline.exoflux.co.uk/html/

    $(function() {
 var url = $(this).attr("href");
    $("nav").delegate("a", "click", function(event) {
     event.preventDefault();
        window.location.hash = $(this).attr('href');
        $("#main").slideUp('slow', function(){
         $("#main").load(url + " #main", function()
      {
       $("#main").slideDown('slow');
      });
        });

    });

    $(window).bind('hashchange', function(){
     newHash = window.location.hash.substring(1);
    });

    $(window).trigger('hashchange');
});

Does anyone have any ideas?

+1  A: 

This line:

var url = $(this).attr("href");

should be moved inside the click handler:

$("nav").delegate("a", "click", function(event) {
     var url = $(this).attr("href");
     event.preventDefault();

since you're loading content based on the href of the clicked anchor.

EDIT: or do you intend to get the current url?

var url = window.location.href;

?

karim79
Thankyou karim79, your first suggestion fixed it :) Anyone have any idea now how to make the page load dymanically when the back button is pressed?
Luke