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

Spine JS + JQuery Mobile + Ajax Request #33

Open grigio opened 12 years ago

grigio commented 12 years ago

Ciao, do you have an example with your router and Spine JS? Grazie

azicchetti commented 12 years ago

Ciao, uhm, not yet, but I'd like to add one soon. If you're willing to try and write something, I'll happily add it to the repository.

A presto, Andrea

grigio commented 12 years ago

Grazie per la risposta, unfortunatly am not a so js ninja.

I tried built a basic app via hem/nodejs but it is very clear to me the correct lib loading

grigio commented 12 years ago

This is a basic Spine Loading, which libraries does your routing replace? I think manager and router, but I don't know how to integrate it. Any tips?

require('json2ify') require('es5-shimify') require('jqueryify')

require('spine') require('spine/lib/local') require('spine/lib/ajax') require('spine/lib/manager') require('spine/lib/route') require('spine/lib/tmpl')

Do I need to disable something? https://gist.github.com/2044082

azicchetti commented 12 years ago

I think it replaces route (as a consequence, manager becomes useless). As long as you use spine for its models and views and react to jquery mobile events through the jqm router, you should be fine.

You don't have to disable anything in the mobileinit event, default settings are fine

sukima commented 11 years ago

So I'm am very interested in also integrating Spine with JQM. I would be more then happy to make a sample app if not a tutorial and share it when complete. However, I would need some help getting started. Maybe a quick overview between JQM design and Spine design and their differing conflicts.

If anyone is interested in chatting or offering some guidance on where to get started I can at least finish with a working example you can add to the documentation.

azicchetti commented 11 years ago

Hi @sukima although I don't know much about spine, I'm quite used to jQM and backbone.js and I know the problems you have to solve to successfully integrate them.

The biggest issue is that jQM has a built-in routing system based on hashes (pushState is also supported) that conflicts with the one provided by backbone and spine.

In addition, jQM provides a lot of useful page-related events that cannot be exploited using a standard hashchange router.

Some folks prefer to disable jQM routing completely and use it as a mobile UI library: this is fine, some things will be probably prove a little more difficult since you have to do a lot of things "by hand".

Alternatively you can keep jQM internal routing and do away with backbone/spine routing plugins. The only requisite is a perfect understanding of the events exposed by jQM ( http://jquerymobile.com/demos/1.2.0/docs/api/events.html ). To tap into jQM routing you have to use events; unfortunately, manually binding handlers to page divs or to the document object is somehow difficult, error prone and time consuming. Some plugins were written to simplify this task and this project is one of them.

To sum everything up, plugins such as the jquerymobile router try to provide the same functionality (or a big subset) of backbone and spine routers by using jQM events, exposing them to the developer in the process.