Advertisement
Guest User

Untitled

a guest
Nov 6th, 2015
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.onload = function() {
  2.  
  3.       var dhx_application = $dhx.ui.mvp.application.extend({
  4.         initialize: function(options) {
  5.           console.log('called initialize from factory');
  6.           //console.log('app initialized from ' + options.from );
  7.         }
  8.       });
  9.  
  10.       var dhx_router = $dhx.ui.mvp.router.extend({
  11.         presenter: {
  12.           start: function() {
  13.             console.log('start from presenter defined by user');
  14.           },
  15.           taskCrud: function() {
  16.             console.log('hello from taskCrud');
  17.           }
  18.         },
  19.         // "someMethod" must exist at presenter.someMethod
  20.         appRoutes: {
  21.           "/task/crud": "taskCrud"
  22.         },
  23.  
  24.         /* standard routes can be mixed with appRoutes/presenters above */
  25.         routes: {
  26.           "/client/crud": "clientCrud"
  27.         },
  28.  
  29.         clientCrud: function() {
  30.           console.log('hello from clientCrud');
  31.         }
  32.       });
  33.  
  34.       // lets use the events
  35.       dhx_application.on('before:start', function(options) {
  36.         console.log('fired onBeforeStart event 1');
  37.         console.log('options ', options);
  38.         return true;
  39.       });
  40.  
  41.       dhx_application.on('before:start', function(options) {
  42.         console.log('fired onBeforeStart event 2');
  43.         console.log('options ', options);
  44.         return true;
  45.       });
  46.  
  47.       dhx_application.on('start', function(options) {
  48.         console.log('fired onStart event');
  49.         console.log('options ', options);
  50.       });
  51.  
  52.       // instantiate $dhx MVP application and router
  53.       var app = new dhx_application({
  54.           appId: "My DhtmlX Application",
  55.           container: document.body,
  56.           root: '/router/'
  57.         }),
  58.         router = new dhx_router({});
  59.  
  60.      
  61.       //router.appRoute("/foo", "fooThat");
  62.      
  63.       //router.processAppRoutes(myController, {
  64.       //  "foo": "doFoo",
  65.       //  "bar/:id": "doBar"
  66.       //});
  67.  
  68.       // start application and render presenter
  69.       app.start();
  70.  
  71.       document.getElementById('link').onclick = function(e) {
  72.         e.preventDefault()
  73.         router.dispatch('/task/crud', true);
  74.       }
  75.  
  76.       document.getElementById('link2').onclick = function(e) {
  77.         e.preventDefault()
  78.         router.dispatch('/client/crud', true);
  79.       }
  80.  
  81.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement