• require.js+backbone.js基本使用


    一、菜单
    {
    //银行卡基础信息维护
    rsId: 'menu.param.cardbin',
    iconCls: 'icon-double-angle-right',
    name: menusLang._('menu.param.cardbin'),
    url: '#',
    deps: ['app/param/card-bin/card-bin-app'],// app/param/card-bin/list/list-view
    trigger: 'card-bins:list'
    }

    二、第二步
    define(['app'],
    function(App) {
    App.module('CardBinApp', function(CardBinApp) {
    var CardBinAppRouter = Marionette.AppRouter.extend({
    appRoutes: {
    "card-bins(/filter/kw::kw)": "listCardBins"
    }
    });

    /////////////////////////////////////////////////////////////////
    // define methods for interaction (with parent app) and router //
    /////////////////////////////////////////////////////////////////
    var API = {

    listCardBins: function(kw) {
    console.log('>>>>param-sys.listCardBins ' + (kw || ''));
    require(['app/param/card-bin/list/list-controller'], function (ctrl) {
    ctrl.listCardBins(kw);
    });
    }

    };

    //if it is not used to map the url first time typed in browser
    //u can new router anywhere before u want, otherwise, u should
    //add router before start Backbone history
    new CardBinAppRouter({ controller: API });


    /////////////////////////////////////////////////
    //register events or command to parent app //////
    /////////////////////////////////////////////////
    App.on('card-bins:list', function(kw) {
    API.listCardBins(kw);
    });


    //this callback will be invoked before parent app:initilize:after
    App.addInitializer(function() {

    console.log('>>>>new CardBinAppRouter');

    });

    });

    return App.CardBinApp;

    });

    三、第三步 controller
    define(['app'], function(App) {
    App.module('aaa.bbb', function(List, App, Backbone, Marionette, $, _) {
    List.Controller = {
    listCardBins: function(kw) {
    require([''], function(View) {
    var xxx = new View.xxxx({});
    App.show(xxx);
    });
    }
    };
    });
    return aaa.bbb.Controller;
    });

    四、list-view
    define(['app'], function(App, paramLang) {
    App.module('aaa.bbb.View', function(View, App, Backbone, Marionette, $, _) {
    View.xxxx = .....
    });
    return aaa.bbb.View;
    });

  • 相关阅读:
    性能篇系列—stream详解
    Java正则表达式详细解析
    干货系列性能篇之——序列化
    面试官之问:知道你的接口“QPS”是多少吗?
    Java性能之优化RPC网络通信
    Spring之 JDBC 异常
    Java性能之synchronized锁的优化
    浅谈Java中switch分支语句
    Spring Boot 之异步执行方法
    Java性能 -- Lock优化
  • 原文地址:https://www.cnblogs.com/babyfacer/p/4777903.html
Copyright © 2020-2023  润新知