Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.onload = function() {
- var dhx_application = $dhx.ui.mvp.application.extend({
- initialize: function(options) {
- console.log('called initialize from factory');
- //console.log('app initialized from ' + options.from );
- }
- });
- var dhx_router = $dhx.ui.mvp.router.extend({
- presenter: {
- start: function() {
- console.log('start from presenter defined by user');
- },
- taskCrud: function() {
- console.log('hello from taskCrud');
- }
- },
- // "someMethod" must exist at presenter.someMethod
- appRoutes: {
- "/task/crud": "taskCrud"
- },
- /* standard routes can be mixed with appRoutes/presenters above */
- routes: {
- "/client/crud": "clientCrud"
- },
- clientCrud: function() {
- console.log('hello from clientCrud');
- }
- });
- // lets use the events
- dhx_application.on('before:start', function(options) {
- console.log('fired onBeforeStart event 1');
- console.log('options ', options);
- return true;
- });
- dhx_application.on('before:start', function(options) {
- console.log('fired onBeforeStart event 2');
- console.log('options ', options);
- return true;
- });
- dhx_application.on('start', function(options) {
- console.log('fired onStart event');
- console.log('options ', options);
- });
- // instantiate $dhx MVP application and router
- var app = new dhx_application({
- appId: "My DhtmlX Application",
- container: document.body,
- root: '/router/'
- }),
- router = new dhx_router({});
- //router.appRoute("/foo", "fooThat");
- //router.processAppRoutes(myController, {
- // "foo": "doFoo",
- // "bar/:id": "doBar"
- //});
- // start application and render presenter
- app.start();
- document.getElementById('link').onclick = function(e) {
- e.preventDefault()
- router.dispatch('/task/crud', true);
- }
- document.getElementById('link2').onclick = function(e) {
- e.preventDefault()
- router.dispatch('/client/crud', true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement