Giter VIP home page Giter VIP logo

Comments (5)

knightcode avatar knightcode commented on July 23, 2024

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.

azicchetti avatar azicchetti commented on July 23, 2024

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.

knightcode avatar knightcode commented on July 23, 2024

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.

knightcode avatar knightcode commented on July 23, 2024

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.

azicchetti avatar azicchetti commented on July 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.