Jquery-mobile backbone.js routing

I have a backbone.js / jquery mobile app:

when I do a GET for mydomain.com/#map, then jquery does "/" and then loads #map.

because "/" is started first, all backbone.js scripts are loaded, including the backbone.js routes in my map-controller.js ("map": "functionForMapRoute"). since the url contains / # map, the backbone.js route "map" is started before jQuery mobile provided dom.

therefore the function "functionForMapRoute" cannot work on a div because the DOM is not fully loaded at this point.

How can I guarantee that the "map" route only starts until the DOM is fully loaded?

+3
source share
3 answers

use something more integrated with jQuery mobile like jquerymobile-router (you can find it on github). It replaces the base router and can be used with jQuery mobile and backbone.js or spine.js

+4
source

I realized that if you do not use "/" in the base router, this will be fine.

eg:.

using

"category-:id": "category"

instead of this

"category/id/:id": "category"

I guess that is why they used the same concept in the official tutorial: P http://jquerymobile.com/test/docs/pages/Backbone-Require/js/routers/mobileRouter.js

"category?:type": "category"
+4
source

I had the same problem and here is the solution to avoid using jquerymobile-router: Backbone.js and jQueryMobile routing without hacking or another router

0
source

All Articles