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

examples / test-bC.html not working #45

Closed RobertCZ closed 12 years ago

RobertCZ commented 12 years ago

I get "can't set unsupported route bC", but even when I change it to "bc" it doesnt work "c.data("page") is undefined"

...content").scrollTop(i):c.scrollTop(i));f=(a.mobile.transitionHandlers[f||"none"]...

Please fix and/or explain, this is exactly the way I'd like to use it (create whole page in the DOM from template, pre-render lots of math and THEN call changePage manually)

PS I just copied the example as-is, local jqm router v0.81

azicchetti commented 12 years ago

Il 10/05/2012 13:42, RobertCZ ha scritto:

I get "can't set unsupported route bC",

Hi, you have to use the -dev version. The following events are still 'staging' in dev: pagebeforechange, pagebeforeload, pageload

Please fix and/or explain, this is exactly the way I'd like to use it (create whole page in the DOM from template, pre-render lots of math and THEN call changePage manually)

If you want to manually insert pages in the dom, in response to a certain user action (for instance, a click on an anchor that points to a page that doesn't yet exist in the dom), you may want to try the pagebeforeload event. Remember to read carefully the documentation on the jquery mobile website, in particular pay attention to the deferred object you have to resolve.

RobertCZ commented 12 years ago

Thanks, will try the dev version

It doesnt really matter whether page is already in the dom, basically, I want to show page async. I tried something like

'slowPage': { events: 'bs', handler () { showHourglass() longPageRendering(function onRendered() { hideHourglass() startPageTransition() )}}

but I dont know how to tell jqm router to start the page transition when rendering is done. Is there a simpler way?

jeffbski commented 12 years ago

It appears that if you try to use jquery.mobile.router.js then bc does not work (no errors, just doesn't fire). Trying to use bC with this script throws error unsupported bC

Using the dev js version (jquery.mobile.router-dev.js) then bC works but bc does not.

azicchetti commented 12 years ago

Hi, the pagebeforechange event (bC) is supported only in the -dev version, at the moment.

Pagebeforecreate, however, should work with either one. Please make sure that the router is instantiated as soon as possible in your application, since this event may be dispatched long before document ready (or pageinit).

examples/test.html and examples/testAjax.html show a couple of routes with this event. If you still have problems, please post some code so I can be more helpful.

Cheers, Andrea

jeffbski commented 12 years ago

Andrea,

Thanks I didn't realize that bC and bc were talking about different events.

I think pagebeforeload and/or pagebeforechange are the main events I will work with to dynamically load custom pages.

I appreciate the response, keep up the great work. Seems to be a wonderful project for jquery mobile.

Jeff