zoukankan      html  css  js  c++  java
  • seajs.的使用

    页面的引用
    <script>
        var app = {};
        app.debug = false;
        app.controller = 'echart/echartControl';
    </script>
     

    <#-- 页脚开始 -->
    <#include "/default/admin/commons/footer.ftl">


    页面页脚footer.ftl引用:
    <script src="/resources/assets/libs/seajs/seajs/2.1.1/sea.js?1.5.3"></script> <script src="/resources/assets/libs/seajs/seajs-style/1.0.1/seajs-style.js?1.5.3"></script> <script src="/resources/assets/libs/seajs-global-config.js?1.5.3"></script> <script> seajs.use("/resources/bundles/schoolweb/js/app.js?1.5.3"); </script>
    app.js

    define(function(require, exports, module) { window.$ = window.jQuery = require('jquery'); require('placeholder'); require('bootstrap'); require('common/bootstrap-modal-hack'); exports.load = function(name) { require.async('./controller/' + name + '.js?' + window.app.version, function(controller){ if ($.isFunction(controller.run)) { controller.run(); } }); }; window.app.load = exports.load; if (app.controller) { exports.load(app.controller); } $(document).ajaxError(function(event, jqxhr, settings, exception) { var json = jQuery.parseJSON(jqxhr.responseText); error = json.error; if (!error) { return ; } if (error.name == 'Unlogin') { $('.modal.in').modal('hide'); $("#login-modal").modal('show'); $.get($('#login-modal').data('url'), function(html){ $("#login-modal").html(html); }); } }); if ($('html').hasClass('lt-ie8')) { var message = '<div class="alert alert-warning" style="margin-bottom:0;text-align:center;">'; message += '您的浏览器版本太低,不能正常使用本站,请使用'; message += '<a href="http://windows.microsoft.com/zh-CN/internet-explorer/downloads/ie" target="_blank">IE8浏览器</a>、'; message += '<a href="http://www.baidu.com/s?wd=%E8%B0%B7%E6%AD%8C%E6%B5%8F%E8%A7%88%E5%99%A8" target="_blank">谷歌浏览器</a><strong>(推荐)</strong>、'; message += '<a href="http://firefox.com.cn/download/" target="_blank">Firefox浏览器</a>,访问本站。'; message += '</div>'; $('body').prepend(message); } $( document ).ajaxSend(function(a, b, c) { if (c.type == 'POST') { b.setRequestHeader('X-CSRF-Token', $('meta[name=csrf-token]').attr('content')); } }); });

     admin-app.js:用于加载其他的js

    define(function(require, exports, module) {
        window.$ = window.jQuery = require('jquery');
    
        require('placeholder');
    
        require('bootstrap');
        require('common/bootstrap-modal-hack');
    
        exports.load = function(name) {
            require.async('./controller/' + name + '.js?' + window.app.version, function(controller){
                if ($.isFunction(controller.run)) {
                    controller.run();
                }
            });
        };
        
        window.app.load = exports.load;
    
        if (app.controller) {
            exports.load(app.controller);
        }
    
        $( document ).ajaxSend(function(a, b, c) {
            if (c.type == 'POST') {
                b.setRequestHeader('X-CSRF-Token', $('meta[name=csrf-token]').attr('content'));
            }
        });
    
    });
  • 相关阅读:
    zoj 2913 Bus Pass
    poj 2478 Farey Sequence
    zoj 1649 Rescue
    秒懂JavaScript HTML DOM 元素 (节点)
    看了就会的JS(JavaScript)addEventListener()
    秒懂javascript的原型(prototype)对象、原型链的前世今生
    构造函数用途及优缺点
    一文读懂 js(JavaScript)中call() 和 apply() 的用法
    js (JavaScript)函数声明的几种形式及用法
    JavaScript 代码规范
  • 原文地址:https://www.cnblogs.com/hanbingljw/p/3992777.html
Copyright © 2011-2022 走看看