js 數據加載loading封裝


<!-- 模態框(Modal) -->
<div class="modal fade" id="qst_loading" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="z-index: 9999">
    <div class="modal-dialog">
        <div class="modal-content" style="width: 0px; text-align: center">
            <div class="modal-body" >
            </div>
        </div><!-- /.modal-content -->
        {{ image("static/background/image/loading.gif", "alt":"loading", "style":"max-width: 200px; margin:200px 100px 100px 200px") }}
    </div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->
/*
* 1、這個封裝外層包裹自執行函數,只要引入此文件,js 就會自動執行
* 2、if('undefined' == typeof QstLoading) 首先判斷QstLoading函數名有沒有被使用,避免覆蓋其他方法
* 3、定義一個匿名函數,使用new構造函數,意思是創建一個新的對象QstLoading ,並分配一個新地址,改變this指向,指向QstLoading ,(this )
* 4、為新對象添加屬性show和hide
* 5、QstLoading 沒有聲明,成為全局對象(不建議此種方法成為全局)
*/



/*
* 1、這個封裝外層包裹自執行函數,只要引入此文件,js 就會自動執行
* 2、if('undefined' == typeof QstLoading) 首先判斷QstLoading函數名有沒有被使用,避免覆蓋其他方法
* 3、定義一個匿名函數,使用new構造函數,意思是創建一個新的對象QstLoading ,並分配一個新地址,改變this指向,指向QstLoading ,(this )
* 4、為新對象添加屬性show和hide
* 5、QstLoading 沒有聲明,成為全局對象(不建議此種方法成為全局)
*/
$(function() {
        if('undefined' == typeof QstLoading){
            QstLoading = new function () {
                var _modal = $('#qst_loading');
                $(_modal).modal({
                    keyboard: false,
                    backdrop: 'static',
                    show: false
                });
                this.show = function () {
                    $(_modal).modal("show");
                };
                this.hide = function () {
                    $(_modal).modal('hide');
                }
            }();
        }
    });

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM