azicchetti/jquerymobile-router

No issue - design question

Opened this issue · 1 comments

My app is based on jQM, this router, backbone.js, require.js and runs on node.

The app routes and handlers reside all in one file. While the app is growing this file becomes quite huge. Is my approach the preferred design or is the a better way?

Hi,
a huge 'controller' file may be difficult to handle as you've noticed.
You can split its content across multiple files as you're probably doing with your views and models.

For instance, you can define a certain namespace:

App.Router

and add the functions you need, using either $.extend or simple assignments (App.Router.aCertainHandler=function(){... ).

The files containing your routes may be loaded in your index.html file with <script> tags, programmatically during the boot of your application, or 'on demand' when they're really needed.