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

How to call Controllers from router? #7

Closed matt-d-rat closed 12 years ago

matt-d-rat commented 12 years ago

Hi, I have been looking at using your plugin as a means to route calls to my controllers which I am using jQueryMX (part of the JMVC framework) for.

I have set up a the router to match against controller & action params, and am using router.getParams() to get their values. Any idea how I would go about mapping these to call a specific controller and action?

azicchetti commented 12 years ago

Il 29/11/2011 02:25, Matt Fairbrass ha scritto:

Hi, I have been looking at using your plugin as a means to route calls to my controllers which I am using jQueryMX (part of the JMVC framework) for.

I have set up a the router to match against controller& action params, and am using router.getParams() to get their values. Any idea how I would go about mapping these to call a specific controller and action?

Hi Matt, I admit I didn't know jQueryMX since, well, a couple of minutes ago...

I'm afraid that jquery.mobile.router won't work on such a framework, because it requires the jquerymobile stack and its event system.

However, if you're targeting mobile devices in your website/application, I suggest you have a look at the jquery mobile (provides the UI) + backbone.js (models and views) stack, it's really powerful, easy to use and learn.

If you're not interested in mobile development, I think you have to use the jquery/event/hashchange/hashchange.js plugin in your jQuery MX application. As far as I can remember its usage is quite straightforward.

Cheers, Andrea