Changing URL after ajax event.

Changing URL after ajax event.

So I have a navigation I am working on that could be adaptable to any site. You click on a link and new content arrives with fade in / out. Pretty standard. However, I would like the URL to change so it can be copy/pasted and/or bookmarked. The code below works, but the fades don't work. Also, I know this 'breaks the back button' and I plan to tackle that next.


  1. $(document).ready(function() {

  2. $("#nav a").click( function ( event ) {
  3. event.preventDefault();
  4. if ( !$(this).is(".current") ) {
  5. var url = $( this ).attr( "href" );
  6. $( "#nav a" ).removeClass( "current" );
  7. $( this ).toggleClass( "current" );
  8.   
  9. $( "#content-container" ).fadeOut( "slow", function() {
  10. $("#content-container")
  11. .load( url + " .content" )
  12. .fadeIn(1500);

  13. });

  14. window.location.replace(url);
  15. };
  16. });

  17. /* This Ends click */

  18. });
  19. /* This ends jQuery */