Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ajax远程记载页面 #13

Open
amu1433 opened this issue May 30, 2014 · 1 comment
Open

ajax远程记载页面 #13

amu1433 opened this issue May 30, 2014 · 1 comment

Comments

@amu1433
Copy link

amu1433 commented May 30, 2014

/**
 * ajax远程加载页面
 */
var loadPage = function(hash){
    var id = _formatHash(hash);
    //优先从remotePage中寻找是否有对应的url,没有则根据id自动从basePagePath中装载
    var url = J.settings.remotePage[id]||J.settings.basePagePath+id+'.html'
    if(!url){
        console.error(404,'页面不存在!');
        return;
    }
    if(J.settings.showPageLoading){
        J.showMask('正在加载...');
    }
    $.ajax({
        url : url,
        timeout : 10000,
        async : false,
        success : function(html){
            if(J.settings.showPageLoading){
                J.hideMask();
            }
            //添加到dom树中
            $('#section_container').append(html);
            //触发pageload事件
            $('#'+id).trigger('pageload');
            //构造组件
            J.Element.init(hash);
        }
    })
}

var url = J.settings.remotePage[id]||J.settings.basePagePath+id+'.html'

这个url我想从动态获取怎么实现啊

  • @shixy
    Copy link
    Owner

    shixy commented Jun 3, 2014

    J.launch({
    remotePage : {
    '#section_id : '你的远程路径地址'
    }
    })

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants