Comments (5)
Found the cause of my error. I forgot to fill in the events property of my Backbone View.
Differentiating the path given to handlers is still a question, though.
from jquerymobile-router.
Hi,
the error is probably thrown by some code executed in an handler bound with the router (probably the #index handler).
As you've noticed, the typical url built by jquery mobile is in this form: #sourcepage&ui-page=something
To match this url, you need a smart regular expression, 'cause a simple #sourcepage regexp (#index in your case) would match for every single page, even the nested ones.
For instance, you could use:
"#index([?&].*)?": "yourHandler"
This will match urls with hash parameters (#index?id=foo&bar=baz) and nested pages (#index&ui-page=foo-1).
By examining the second group in the regular expression result (match[1]) you can find out which subpage is being rendered.
edit:
You may also want to use two different regexp's for the main page:
"#index$"
and for the subpages:
"#index[&](.*)"
Cheers,
Andrea
from jquerymobile-router.
Hi,
Thanks for the info. But I'm actually using this regex for the main page:
"^index$"
And the problem is that all the pages are matching it despite each of JQM's pages for the sublists having something like:
data-url="index&ui-page=0-0"
I would construct a separate regex for the sublists if it seemed like JQM (or something) reported a different route/path for them, but that doesn't seem to be what's happening.
I should note that I have this problem this is the initial page being loaded. Haven't yet observed its behavior when navigating to the page.
As a work-around, I've found that the main page has a class called 'ui-body-c' where the sub list pages have 'ui-body-null'. I can check for the class in my handler and differentiate the actions to take.... but it's a hack.
from jquerymobile-router.
Hi,
Seems to happen when navigating to the page as well except that the path/route is the appropriate url of the page. So, for instance, with a url like:
/foo/bar/
and a regex:
"/foo/bar/(?:[^#]*)?$"
fires the associated handler multiple times, say for the 'pageinit' event, with match[0] == '/foo/bar/'.
Let me know if I'm doing something wrong or if I can help debug at all. Thank you!
from jquerymobile-router.
Hi,
the suggested solution should work for a single-file multipage template (that is to say, your application doesn't load pages through ajax).
In order to debug this issue, I need to know whether you're using ajax or not.
The "^index$" regexp shouldn't match in a multipage environment, due to the missing "#".
Could you please send me a zip file with your test case?
Thank you.
from jquerymobile-router.
Related Issues (20)
- Not an issue actually but the request to provide more advanced example HOT 3
- jQM 1.3.0 HOT 8
- Examples don't work HOT 2
- default handler not called HOT 3
- Routing issues with JQM 1.3.1 and knockout.js HOT 3
- Early Router - Too late for first page? HOT 2
- Debugging snippet gets in the way HOT 4
- URI parameters are striped out when using new pagebeforechange event HOT 4
- Loading the first page via bc handler HOT 6
- handler getting called twice even when step "url" selected HOT 1
- With requireJs, router initialises after jQuery Mobile page events trigger HOT 2
- How does one access the data object resultant from a $.mobile.navigate('#target',{}) invocation HOT 1
- production ready? HOT 1
- e.preventDefault() on a re-routing system HOT 1
- Are urls like this "#category/:id/items" possible? HOT 1
- Can this be used using two different html files? HOT 4
- Back Problem HOT 2
- Bower support HOT 1
- defaultHandler is not invoked when customer handlers are not specified
- Am I right that this plugin doesnt work in jqmobile 1.4.5 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquerymobile-router.