zoukankan      html  css  js  c++  java
  • 将数据加载时显示的图片和文字提成公共的--实现方法

    1. 页面引入loading.js。且在页面上添加<div id="loading"></div>
    2. 加载数据之前进行调用。调用方法如下:
    loading = new loadingObj($("#loading"), buildURI("images/"));
    loading.init();
    loading.show();
    $("#service_slist").hide();
    $("#listArea").empty();
    $("#pageArea").empty();
    $("#fw_empty").hide();
    if(typeof window.xhrCache != 'undefined') {
        typeof window.xhrCache.abort == 'function' && window.xhrCache.abort();
    }
    window.xhrCache = $.ajax( {
        type : "post",
        dataType : "text",
        url: url,
        data: data,
        success :     function(res){    
            loading.hide();
            ………………………………
            }
        });

    loading.js

    var loadingObj = function(viewObj, imgPathPrefix){
        var imgName = "loading_pa.gif";
        this.css = ".loading_box{background:url("+ imgPathPrefix + imgName +") center top no-repeat; padding-top:30px; 100%; font-size:12px; text-align:center; color:#cccccc;}";
        this.html = "<div class='loading_box'>正在加载中,请稍后...</div>";
        this.viewObj = viewObj;
    }
    
    loadingObj.prototype = {
        init: function(){
            var style = $("<style>"+ this.css +"</style>");
            var head = $("head").length > 0 ? $("head").eq(0) : $("head");
            style.appendTo(head);
            this.viewObj.html(this.html);
        },
        show: function(){
            this.viewObj.show();
        },
        hide: function(){
            this.viewObj.hide();
        }
    };
  • 相关阅读:
    cpu降频问题
    配置 logrotate 指导
    Ubuntu 和 Ros 对应版本关系
    Git 文件管理
    Win10(UEFI启动) 安装Ubuntu16.04双系统
    Clion ROS开发环境设置
    clion 创建快捷方式和配置ros开发环境
    Ubuntu 16.04安装 CastXML
    eigen3 版本信息查看
    ubunutu eigen3包的查找
  • 原文地址:https://www.cnblogs.com/kevin-yuan/p/3547751.html
Copyright © 2011-2022 走看看