azicchetti / jquerymobile-router

A router/controller for jquery mobile. Also adds support for client-side parameters in the hash part of the url. The routes handles regexp based routes. This plugin can be used alone or (better) with Backbone.js or Spine.js, because it's originally meant to replace their router with something integrated with jQM.
GNU General Public License v2.0
402 stars 69 forks source link

No issue - design question #44

Closed ghost closed 12 years ago

ghost commented 12 years ago

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?

azicchetti commented 12 years ago

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 Githubissues.

  • Githubissues is a development platform for aggregating issues.