<!-- 模態框(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'); } }(); } });