-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Bad URLs with hashes are not gracefully handled #4119
Comments
Yeah, this is a bug for sure. In fact, an empty hash should probably be ignored too (/#), right now it navigate you to the root. |
Double hash, or any form of bad URL, is not necessary — any (legitimate) hash will break init, eg: http://jquerymobile.com/demos/1.1.0/#jqm-logo From my execution, no errors are thrown, and no custom events are fired — the page rests in a loading state and initialisation is frozen. EDIT: You can prevent this behaviour by executing |
I'm also running across this when trying to load deeplinks using my multiview plugin, because by default my some.html#nested_page_ID will also be a bad URL. I have patched my JQM like this to fix it for me:
I'm trying to get by without touching JQM.js, so in case you are adding some more logic and are open for wishes... I would also like a custom event such as "loadFirstPage" to tap into. I guess once you start thinking about supporting anchor tags, you will need some more logic here anyway, because all anchor tags will be bad as of now. What do you think? |
Thinking more about a loadFirstPage event.... this would also be very useful for deeplinks to artifical hashtags. Say I have a page some.html, in which I'm updating content via Ajax. I would like to reflect the updated page by changing the hashtag, but I can't because all deeplinks to this page ala some.html#new_content will break, because the page isn't there and I'm missing an event to tap into the first page being loaded to redirect to the actual page and fire an Ajax call to update the content. No problem on the 2nd page with pagebeforechange, but on the first page, this does not fire, does it? If I could do:
|
Just to note, based on this proposed fix: when hash listening is enabled, things still break. |
Fixes jquery-archive#4119 - Bad URLs with hashes are not gracefully handled
Fixes issue #4119 Added regex test to see if hash is valid and if a page with that id exists, if not load the first page. Added unit tests for isHashValid
I'm not sure if this is by design or not, but
http://jquerymobile.com/demos/1.1.0/##
Is a decent example of this.
I'd expect the page to just load at this point, instead it freezes with a JS error. This is likely caused by the way that hash changes are handled.
The text was updated successfully, but these errors were encountered: