0
votes

In early version Marionette we could use Marionette Controller

return Marionette.AppRouter.extend({
    appRoutes: {
        'admin/:controller/:action(?:query)': "controllerThird",
        '*notFound': "error"
    },
    controller: new Controller()
})

return Marionette.Controller.extend ({
    controllerThird: function (controller, action, query) {
        this.start(action);
    }
})

but now Marionette.Controller

Warning: deprecated. The Controller object is deprecated. Instead of using the Controller class with the AppRouter, you should specify your callbacks on a plain Javascript object or a Marionette Object

We use MVC controller like

function (Backbone, Marionette, controller){

    "use strict";

    var AppRouter = Backbone.Marionette.AppRouter.extend({

        appRoutes: {

            "path1" : "goto_path1",
            "path2" : "goto_path2",
            "path3" : "goto_path3"
        }

    });

    return new AppRouter({controller: controller});

});

  define([
  'jquery',
  'underscore',
  'backbone',
  'marionette',
  'app',
  'userSession'
], 
function($, _, Backbone, Marionette, App, userSession) {

    return {
        goto_path1: function () {
                //I need get current query in this point 

        },
});

https://stackguides.com/questions/11410059/suggested-bootstrap-boilerplate-sample-for-backbone-marionette-application

In Controller handler I want access to action, query params like

controllerThird: function (controller, action, query)

How can I do this ?

1

1 Answers

0
votes

You can actually keep most of your existing code and it will still work. It's as simple as what the deprecation message suggests.

Simply replace the Controller

return Marionette.Controller.extend ({
    controllerThird: function (controller, action, query) {
      this.start(action);
    }
})

With a Marionette Object:

return Marionette.Object.extend ({
    controllerThird: function (controller, action, query) {
      this.start(action);
    }
})

See here for a more extensive example

https://marionette.gitbooks.io/marionette-guides/content/en/appendix/approuter/router.html#router-and-controller