Permalink
Browse files

Fixes #2570 - Refreshing a page with #&ui-state=dialog causes syntax…

… error

- This was a regression from my fix to loadPage() for detecting un-enhanced pages by @id as a fallback. In this particular case dataUrl was being used to create an id selector, and of course if the dataUrl is an empty string we end up using "#" as the selector. The fix is to simply check for a non-empty dataUrl.
  • Loading branch information...
jblas committed Sep 29, 2011
1 parent 836eae8 commit 47812171f10ee1b28dcc63615cb4a764fb49d2da
Showing with 1 addition and 1 deletion.
  1. +1 −1 js/jquery.mobile.navigation.js
@@ -737,7 +737,7 @@
// reference to an embedded page. If so, it may have been dynamically
// injected by a developer, in which case it would be lacking a data-url
// attribute and in need of enhancement.
- if ( page.length === 0 && !path.isPath( dataUrl ) ) {
+ if ( page.length === 0 && dataUrl && !path.isPath( dataUrl ) ) {
page = settings.pageContainer.children( "#" + dataUrl )
.attr( "data-" + $.mobile.ns + "url", dataUrl )
}

11 comments on commit 4781217

@adaptabi

This comment has been minimized.

Show comment
Hide comment
@toddparker

This comment has been minimized.

Show comment
Hide comment
@toddparker

toddparker Jan 23, 2012

Contributor
Contributor

toddparker replied Jan 23, 2012

@adaptabi

This comment has been minimized.

Show comment
Hide comment
@adaptabi

adaptabi Jan 24, 2012

Contributor

Not really - Check out a demo: http://www.dotnetwise.com/tryAndError/jquery.mobile/select.filter/

Also a link from the latest code version where you can reproduce the error -> http://code.jquery.com/mobile/latest/demos/docs/lists/lists-nested.html#&ui-page=0-4

Delete the hash and the error will go away!

Contributor

adaptabi replied Jan 24, 2012

Not really - Check out a demo: http://www.dotnetwise.com/tryAndError/jquery.mobile/select.filter/

Also a link from the latest code version where you can reproduce the error -> http://code.jquery.com/mobile/latest/demos/docs/lists/lists-nested.html#&ui-page=0-4

Delete the hash and the error will go away!

@toddparker

This comment has been minimized.

Show comment
Hide comment
@toddparker

toddparker Jan 24, 2012

Contributor

Thanks for re-testing on latest. I see the issue you're talking about now, that is helpful. This looks like a server-side error so is this an issue on that side?

Contributor

toddparker replied Jan 24, 2012

Thanks for re-testing on latest. I see the issue you're talking about now, that is helpful. This looks like a server-side error so is this an issue on that side?

@adaptabi

This comment has been minimized.

Show comment
Hide comment
@adaptabi

adaptabi Jan 24, 2012

Contributor

What server error?
There are two errors:

  1. The page won't load because the hash is broken (jqm client side error)
  2. jqm will break the hash and that will exceed to query string, which may give a server error, or not - but again this is caused by jqm hash handling.

Likewise, the hash, never reaches the server, so if jqm would parse it properly then the page would load correctly - with that given dialog / list / selectbox as the first "page" displayed

Contributor

adaptabi replied Jan 24, 2012

What server error?
There are two errors:

  1. The page won't load because the hash is broken (jqm client side error)
  2. jqm will break the hash and that will exceed to query string, which may give a server error, or not - but again this is caused by jqm hash handling.

Likewise, the hash, never reaches the server, so if jqm would parse it properly then the page would load correctly - with that given dialog / list / selectbox as the first "page" displayed

@toddparker

This comment has been minimized.

Show comment
Hide comment
@toddparker

toddparker Jan 24, 2012

Contributor

I just meant that I was seeing an error like this when I refreshed so it was looking like I was getting essentially a 404:


Server Error in '/' Application.

Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. 
...

Looking at your URL, it looks like you're using nested lists for the two pages - is that right? Nested lists use the &ui-page=0-0 convention in the hash and custom select menus will cause issues because that moves the # when it tacks on a #&ui-state=dialog to the URL so these are competing.

This is clearly a bug but if this works ok if you use a normal, multipage setup or individual pages then this will be low on our priority list. I really want to discourage people from using nested lists to embed full pages like this because it is just too fragile and there are a lot of constraints because we generate the pages (you can't customize the layout for example). Ive been trying to encourage people to either use a multipage setup or singel pages with the prefetch feature. Both will give you the same results, but in a better way.

Contributor

toddparker replied Jan 24, 2012

I just meant that I was seeing an error like this when I refreshed so it was looking like I was getting essentially a 404:


Server Error in '/' Application.

Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. 
...

Looking at your URL, it looks like you're using nested lists for the two pages - is that right? Nested lists use the &ui-page=0-0 convention in the hash and custom select menus will cause issues because that moves the # when it tacks on a #&ui-state=dialog to the URL so these are competing.

This is clearly a bug but if this works ok if you use a normal, multipage setup or individual pages then this will be low on our priority list. I really want to discourage people from using nested lists to embed full pages like this because it is just too fragile and there are a lot of constraints because we generate the pages (you can't customize the layout for example). Ive been trying to encourage people to either use a multipage setup or singel pages with the prefetch feature. Both will give you the same results, but in a better way.

@adaptabi

This comment has been minimized.

Show comment
Hide comment
@adaptabi

adaptabi Jan 24, 2012

Contributor

I see your point, but this is certainly a bug.
I cannot use "separate" pages as you say, since the "address" thing is just part of the "profile page".

The url should never get broken - just the hash needs to be updated in a way that works.
And bare in mind that the has might be used for other stuff as well.
I simply recommend that whatever is after # should be treated the same way as the query string is
i.e. #key1=value1&key2=value2 etc.
This way jqm won't break itself's features nor other components.

Another issue I can see on my Android HTC Desire HD is that the performance is kinda low. Especially when lists/dropdown run their effects.
They execute right, but in the end the list/drop down is shown one more time full, and then is hidden.
I suspect this is just another bug in the jqm.
As far as I have worked through the code, I can see lots of enhancements/optimizations that can be done.
There are surely too many string concatenations and partial objects built and then wrappend into each-other.
As far as I remember this was one of the first things I have learned about optimizing jquery's usage.

Anyway - do you reckon any time soon this error will get fixed?

Contributor

adaptabi replied Jan 24, 2012

I see your point, but this is certainly a bug.
I cannot use "separate" pages as you say, since the "address" thing is just part of the "profile page".

The url should never get broken - just the hash needs to be updated in a way that works.
And bare in mind that the has might be used for other stuff as well.
I simply recommend that whatever is after # should be treated the same way as the query string is
i.e. #key1=value1&key2=value2 etc.
This way jqm won't break itself's features nor other components.

Another issue I can see on my Android HTC Desire HD is that the performance is kinda low. Especially when lists/dropdown run their effects.
They execute right, but in the end the list/drop down is shown one more time full, and then is hidden.
I suspect this is just another bug in the jqm.
As far as I have worked through the code, I can see lots of enhancements/optimizations that can be done.
There are surely too many string concatenations and partial objects built and then wrappend into each-other.
As far as I remember this was one of the first things I have learned about optimizing jquery's usage.

Anyway - do you reckon any time soon this error will get fixed?

@adaptabi

This comment has been minimized.

Show comment
Hide comment
@adaptabi

adaptabi Feb 7, 2012

Contributor

Any news? :)

Contributor

adaptabi replied Feb 7, 2012

Any news? :)

@xsalto-camille

This comment has been minimized.

Show comment
Hide comment
@xsalto-camille

xsalto-camille Mar 5, 2012

Hello,
This correction doesn't work anymore... For example, this page is empty :
http://jquerymobile.com/demos/1.0.1/docs/lists/lists-nested.html#&ui-page=0-8

Hello,
This correction doesn't work anymore... For example, this page is empty :
http://jquerymobile.com/demos/1.0.1/docs/lists/lists-nested.html#&ui-page=0-8

@snig-b

This comment has been minimized.

Show comment
Hide comment
@snig-b

snig-b Jun 20, 2014

Uncaught Error: Syntax error, unrecognized expression: #&ui-state=dialog using jquery 1.10.2 and jquery mobile 1.4.2 as well as 1.3.1
Any updates would be appreciated..

Uncaught Error: Syntax error, unrecognized expression: #&ui-state=dialog using jquery 1.10.2 and jquery mobile 1.4.2 as well as 1.3.1
Any updates would be appreciated..

@snig-b

This comment has been minimized.

Show comment
Hide comment

False Alarm
#2570 (comment)

Please sign in to comment.