哈希交换欠发行问题

时间:2013-04-29 23:58:52

标签: jquery wordpress twitter-bootstrap hash

我在wordpress主题中使用ajax,在单击菜单项时将页面内容全部加载到一个页面上。但是,我需要在同一页面上加载Bootstrap模式。我无法正确获取网址。请参阅以下代码:

jQuery(document).ready(function($) {
    var $mainContent = $("#page-content"),
        siteUrl = "http://" + top.location.host.toString(),
        url = ''; 
    $(document).delegate("a[href^='"+siteUrl+"']", "click", function() {
        location.hash = this.pathname;
        return false;
    }); 
    $(document).undelegate("a[href^''#myModal]", "click");
    $(document).undelegate("a[href^''"/"]", "click")
    $("#searchform").submit(function(e) {
        location.hash = '?s=' + $("#s").val();
        e.preventDefault();
    }); 
    $(window).bind('hashchange', function(){
        url = window.location.hash.substring(1); 
        if (!url) {
            return;
        } 
        url = url + " #page-content"; 
        $mainContent.animate({opacity: "0.1"}).html('<div class="row"><div class="span4 offset3"><img src="http://innovativesites.org/eventaglobal/wp-content/uploads/sites/22/2013/04/Eventa-Logo.jpg" class="vertical-down" alt="Eventa Global"></div></div>').load(url, function() {
            $mainContent.animate({opacity: "1"});
        });
    });
    $(window).trigger('hashchange');
});

0 个答案:

没有答案