Jingle icon indicating copy to clipboard operation
Jingle copied to clipboard

ajax远程记载页面

Open amu1433 opened this issue 10 years ago • 1 comments

/**
 * 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我想从动态获取怎么实现啊

  • amu1433 avatar May 30 '14 07:05 amu1433
  • J.launch({ remotePage : { '#section_id : '你的远程路径地址' } })

    shixy avatar Jun 03 '14 01:06 shixy