2010-06-09 3 views
1

J'ai suivi ce grand tutoriel pour « ajax » mon blog: http://www.deluxeblogtips.com/2010/05/how-to-ajaxify-wordpress-theme.html Mais il crée quelques problèmes et je pense que le problème est dans le hachage qui crée ajax . Donc, après le chargement du contenu, comment puis-je supprimer le hachage de l'URL? copier mon code ici:Retirez le hachage après Ajax chargement (j'ajaxing 8 wordpress))

jQuery(document).ready(function($) { 
    var $mainContent = $("#content"), 
     siteUrl = "http://" + top.location.host.toString(), 
     url = ''; 

    $(document).delegate("a[href^='"+siteUrl+"']:not([href*=/wp-admin/]):not([href*=/wp-login.php]):not([href$=/feed/]):not([href*=/go.php]):not(.comment-reply-link)", "click", function() { 
     location.hash = this.pathname; 
$('html, body').animate({scrollTop:0}, 'fast'); 
     return false; 
    }); 

    $("#searchform").submit(function(e) { 
     location.hash = '?s=' + $("#search").val(); 
     e.preventDefault(); 
    }); 

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

     if (!url) { 
      return; 
     } 

     url = url + " #inside"; 

     $mainContent.html('<div id="loader">Caricamento in corso...</div>').load(url, function() { 
      //$mainContent.animate({opacity: "1"}); 
      scriptss(); 
     }); 
    }); 

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

Merci beaucoup à tous!

+0

Salut Alberto, si une réponse fonctionne pour vous, vous pouvez voter et la marquer comme "acceptée" - la section "Réponses" n'est pas le bon endroit pour un "Merci". – artlung

+0

Merci Alberto! J'espère que vous appréciez StackOverflow! – artlung

Répondre

2

Donc, vous voulez supprimer le hachage? Il suffit de le définir sur une chaîne vide.

window.location.hash = ''; 

Cela va régler votre événement hashchange, mais il semble que vous vérifiez et juste retour si le hachage est vide.

+0

et peut vérifier cela aussi http://stackoverflow.com/questions/2295845/remove-hash-without-page-jump/2295896#2295896 –

Questions connexes