New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass parameters between pages in the URL #2859

Closed
stefanpoeter opened this Issue Oct 27, 2011 · 19 comments

Comments

@stefanpoeter

stefanpoeter commented Oct 27, 2011

Hi,

this ist my situation:

I've got a simple list with links that point to something like

somePage?someId=1

somePage?someId=2

somePage?someId=3

now, when I click on the first link the correct page gets loaded. Going back to that list and clicking another link visits the first page again. I believe it has something to do with not changing the hash correctly. Could it be that the hash is somehow chached and only identifies the #somePage part and not the ?someId=2 part?

Thanks and greetings
Stefan

@toddparker

This comment has been minimized.

Show comment
Hide comment
@toddparker

toddparker Oct 27, 2011

Contributor

Can you post a simplified test page using the latest build and specify step to reproduce and browser/device version info? Template here:
http://jsbin.com/omirod/edit

Contributor

toddparker commented Oct 27, 2011

Can you post a simplified test page using the latest build and specify step to reproduce and browser/device version info? Template here:
http://jsbin.com/omirod/edit

@stefanpoeter

This comment has been minimized.

Show comment
Hide comment
@stefanpoeter

stefanpoeter Oct 28, 2011

http://jsbin.com/omirod/43

Look at the addressbar after clicking link one, going back and clicking link two. The address bar is pointing to #somePage?id=1.

stefanpoeter commented Oct 28, 2011

http://jsbin.com/omirod/43

Look at the addressbar after clicking link one, going back and clicking link two. The address bar is pointing to #somePage?id=1.

@stefanpoeter

This comment has been minimized.

Show comment
Hide comment
@stefanpoeter

stefanpoeter Oct 28, 2011

Appears on the latest Chrome, Firefox and my Android 2.3 Browser.

stefanpoeter commented Oct 28, 2011

Appears on the latest Chrome, Firefox and my Android 2.3 Browser.

@celer

This comment has been minimized.

Show comment
Hide comment
@celer

celer Oct 28, 2011

I'm having this exact same issue(w/rc2), and so are a few others:

https://forum.jquery.com/topic/url-not-updating-with-different-parameters

celer commented Oct 28, 2011

I'm having this exact same issue(w/rc2), and so are a few others:

https://forum.jquery.com/topic/url-not-updating-with-different-parameters

@toddparker

This comment has been minimized.

Show comment
Hide comment
@toddparker

toddparker Oct 28, 2011

Contributor

Can you test this with pushState disabled? I know that some browsers get wonky with forward/back navigation and our pushState code because there is some inconsistency in when popstate is fired across browsers.
http://jquerymobile.com/test/docs/api/globalconfig.html
http://jquerymobile.com/test/docs/config/pushState.html

Contributor

toddparker commented Oct 28, 2011

Can you test this with pushState disabled? I know that some browsers get wonky with forward/back navigation and our pushState code because there is some inconsistency in when popstate is fired across browsers.
http://jquerymobile.com/test/docs/api/globalconfig.html
http://jquerymobile.com/test/docs/config/pushState.html

@celer

This comment has been minimized.

Show comment
Hide comment
@celer

celer Oct 28, 2011

Hi Todd,

Thanks for the suggestion - sadly it didn't fix it. We are doing our testing and development using desktop versions of chrome and firefox, both of which have the same broken URL behavior. This also exhibits similar issues when using the jquery mobile provided back button, i.e. it goes back to the wrong page.

celer commented Oct 28, 2011

Hi Todd,

Thanks for the suggestion - sadly it didn't fix it. We are doing our testing and development using desktop versions of chrome and firefox, both of which have the same broken URL behavior. This also exhibits similar issues when using the jquery mobile provided back button, i.e. it goes back to the wrong page.

@toddparker

This comment has been minimized.

Show comment
Hide comment
@toddparker

toddparker Oct 31, 2011

Contributor

Thanks, we'll prioritize this.

Contributor

toddparker commented Oct 31, 2011

Thanks, we'll prioritize this.

@ghost ghost assigned johnbender Oct 31, 2011

@johnbender

This comment has been minimized.

Show comment
Hide comment
@johnbender

johnbender Nov 2, 2011

Contributor

@celer and @stevepo

We don't currently support query parameters as part of the hash fragment, though this is something that's been discussed frequently internally and is on the feature request list.

For clarity you'll note in the rfc that the fragment is "is indicated by the presence of a number sign ("#") character and terminated by the end of the URI". So if you are looking to provide those parameters as part of a request to a server they need to be moved before the fragment.

Contributor

johnbender commented Nov 2, 2011

@celer and @stevepo

We don't currently support query parameters as part of the hash fragment, though this is something that's been discussed frequently internally and is on the feature request list.

For clarity you'll note in the rfc that the fragment is "is indicated by the presence of a number sign ("#") character and terminated by the end of the URI". So if you are looking to provide those parameters as part of a request to a server they need to be moved before the fragment.

@johnbender

This comment has been minimized.

Show comment
Hide comment
@johnbender

johnbender Nov 2, 2011

Contributor

@jblas

Has been tracking this closely and may have corrections/more to add.

Contributor

johnbender commented Nov 2, 2011

@jblas

Has been tracking this closely and may have corrections/more to add.

@jblas

This comment has been minimized.

Show comment
Hide comment
@jblas

jblas Nov 2, 2011

Contributor

As @johnbender mentioned, we do not officially support query param passing to internal/embedded pages. When jQuery Mobile comes across "#somePage?someId=1" it passes it to jQuery core, which seems to interpret that as "#somePage" so it locates the internal page div, but then it tags it with a data-url of "#somePage?someId=1", which is why subsequent calls to "#somePage?someId=2" find the same div. The reason why it always displays "#somePage?someId=1" is because jQuery Mobile uses the data-url on the div which only gets set once.

I've seen enough of these internal page param requests that I went and wrote a plugin for folks. You can find it here:

https://github.com/jblas/jquery-mobile-plugins/tree/master/page-params

You can take it, modify it, and bend it to your will. There was also a similar discussion in issue #450 where someone else ended up writing a different plugin for use with backbone.js:

https://github.com/azicchetti/jquerymobile-router

My version is just the barebones necessary to get this to work.

Contributor

jblas commented Nov 2, 2011

As @johnbender mentioned, we do not officially support query param passing to internal/embedded pages. When jQuery Mobile comes across "#somePage?someId=1" it passes it to jQuery core, which seems to interpret that as "#somePage" so it locates the internal page div, but then it tags it with a data-url of "#somePage?someId=1", which is why subsequent calls to "#somePage?someId=2" find the same div. The reason why it always displays "#somePage?someId=1" is because jQuery Mobile uses the data-url on the div which only gets set once.

I've seen enough of these internal page param requests that I went and wrote a plugin for folks. You can find it here:

https://github.com/jblas/jquery-mobile-plugins/tree/master/page-params

You can take it, modify it, and bend it to your will. There was also a similar discussion in issue #450 where someone else ended up writing a different plugin for use with backbone.js:

https://github.com/azicchetti/jquerymobile-router

My version is just the barebones necessary to get this to work.

@celer

This comment has been minimized.

Show comment
Hide comment
@celer

celer Nov 4, 2011

Thanks for the feedback! We're trying to provide those parameters to the client side code. I guess perhaps are using jQuery Mobile in a way that was not intended.

Lets say were building a 100% client side app using phone gap, that has no server side component and uses localStorage / lawn chair for storage of data.

Our hope is that we could use the URL to pass parameters between client side pages so that we retain bookmark ability.

For example, lets say I have a simple project, for example an addressbook.

And I have two jQuery mobile pages which are fed from localStorage / etc.

#list - show a list of all the addresses
#view?address=NUMBER

Both of these pages would be populated by jQuery on the fly using localStorage. Again our goal was to retain bookmark ability of these pages, and use the URL to pass the page parameters.

We were just trying to cheat a little bit - what is the recommended way of passing data parameters back and forth between client side generated pages?

Thanks,

celer

celer commented Nov 4, 2011

Thanks for the feedback! We're trying to provide those parameters to the client side code. I guess perhaps are using jQuery Mobile in a way that was not intended.

Lets say were building a 100% client side app using phone gap, that has no server side component and uses localStorage / lawn chair for storage of data.

Our hope is that we could use the URL to pass parameters between client side pages so that we retain bookmark ability.

For example, lets say I have a simple project, for example an addressbook.

And I have two jQuery mobile pages which are fed from localStorage / etc.

#list - show a list of all the addresses
#view?address=NUMBER

Both of these pages would be populated by jQuery on the fly using localStorage. Again our goal was to retain bookmark ability of these pages, and use the URL to pass the page parameters.

We were just trying to cheat a little bit - what is the recommended way of passing data parameters back and forth between client side generated pages?

Thanks,

celer

@toddparker

This comment has been minimized.

Show comment
Hide comment
@toddparker

toddparker Nov 4, 2011

Contributor

I think that if you use one of the plugin above, then it's a fine way to go. Well look at how much we want to pull in in a future version.

I'm going to keep this open for now, but this is pretty much a feature request. I also edited the title for clarity.

Contributor

toddparker commented Nov 4, 2011

I think that if you use one of the plugin above, then it's a fine way to go. Well look at how much we want to pull in in a future version.

I'm going to keep this open for now, but this is pretty much a feature request. I also edited the title for clarity.

@raldred

This comment has been minimized.

Show comment
Hide comment
@raldred

raldred Mar 8, 2012

I these plugins are not fully compatible with 1.1.0RC1
I have been working with the dev of jquery.mobile.router

This is now and an issue with or without the plugins.

Discussion about jqmr here:
azicchetti/jquerymobile-router#31

raldred commented Mar 8, 2012

I these plugins are not fully compatible with 1.1.0RC1
I have been working with the dev of jquery.mobile.router

This is now and an issue with or without the plugins.

Discussion about jqmr here:
azicchetti/jquerymobile-router#31

@rjsteinert

This comment has been minimized.

Show comment
Hide comment
@rjsteinert

rjsteinert Aug 20, 2012

Patching my 1.1.1 release with flodev's patch fixes the problem for me.

rjsteinert commented Aug 20, 2012

Patching my 1.1.1 release with flodev's patch fixes the problem for me.

@adaptabi

This comment has been minimized.

Show comment
Hide comment
@adaptabi

adaptabi Oct 20, 2012

Contributor

Still a big issue with jqm 1.2

Contributor

adaptabi commented Oct 20, 2012

Still a big issue with jqm 1.2

@jaspermdegroot

This comment has been minimized.

Show comment
Hide comment
@jaspermdegroot

jaspermdegroot Jul 27, 2013

Member

First of all, from the beginning we have been clear about query params not being supported, when using jQuery Mobile's AJAX navigation. There has been a change of behaviour between 1.2 (error) and 1.3 (stripping). We decided that if we make changes again it should be a permanent solution, so we don't keep changing things each version. We didn't have enough time to do this for 1.4 so it has to wait until 1.5.

From the 1.4 changelog: "Deprecated current behaviour of stripping query strings from hashes. Starting in 1.5 we’ll be following spec on hashes and provide a hook to handle custom navigation."

In the meantime we will look into a workaround that can be used with 1.3 and 1.4. When there is one we will inform you about it in a comment on this ticket.

cc: @gseguin

Member

jaspermdegroot commented Jul 27, 2013

First of all, from the beginning we have been clear about query params not being supported, when using jQuery Mobile's AJAX navigation. There has been a change of behaviour between 1.2 (error) and 1.3 (stripping). We decided that if we make changes again it should be a permanent solution, so we don't keep changing things each version. We didn't have enough time to do this for 1.4 so it has to wait until 1.5.

From the 1.4 changelog: "Deprecated current behaviour of stripping query strings from hashes. Starting in 1.5 we’ll be following spec on hashes and provide a hook to handle custom navigation."

In the meantime we will look into a workaround that can be used with 1.3 and 1.4. When there is one we will inform you about it in a comment on this ticket.

cc: @gseguin

@arschmitz

This comment has been minimized.

Show comment
Hide comment
@arschmitz

arschmitz Aug 12, 2013

Member

After discussion we are not going to support query params an as @uGoMobi above indicated instead going to allow any valid id and not have any special handling. Since we are going another direction with this im going to go ahead and close.

Member

arschmitz commented Aug 12, 2013

After discussion we are not going to support query params an as @uGoMobi above indicated instead going to allow any valid id and not have any special handling. Since we are going another direction with this im going to go ahead and close.

@arschmitz arschmitz closed this Aug 12, 2013

@CameronAskew

This comment has been minimized.

Show comment
Hide comment
@CameronAskew

CameronAskew Apr 3, 2014

@stevepo @toddparker @celer @johnbender @jblas @raldred @rjsteinert @dotnetwise @uGoMobi @arschmitz

If anybody still cares about this, I created a simple plug-in which allows you to pass and maintain URL parameters within embedded jQuery Mobile pages for the multi-page template. It works well but could probably use some touch-ups and improvements...which I'll do if people ask for them & time permits..or people can also contribute. You can find the plug-in here..

https://github.com/CameronAskew/jquery.mobile.paramsHandler

CameronAskew commented Apr 3, 2014

@stevepo @toddparker @celer @johnbender @jblas @raldred @rjsteinert @dotnetwise @uGoMobi @arschmitz

If anybody still cares about this, I created a simple plug-in which allows you to pass and maintain URL parameters within embedded jQuery Mobile pages for the multi-page template. It works well but could probably use some touch-ups and improvements...which I'll do if people ask for them & time permits..or people can also contribute. You can find the plug-in here..

https://github.com/CameronAskew/jquery.mobile.paramsHandler

@AaronHarris

This comment has been minimized.

Show comment
Hide comment
@AaronHarris

AaronHarris Nov 19, 2015

I still care. I have to say I hope that in a future version this gets implemented into the main distribution. As previously explained, a tag <a href="#foo?bar=baz">link</a naviagtes only to #foo, which to a newcomer would be unexpected behavior. With the ride of "deep-linking" in mobile applications, it makes more sense to leave the hash as navigated rather than modifying it.

AaronHarris commented Nov 19, 2015

I still care. I have to say I hope that in a future version this gets implemented into the main distribution. As previously explained, a tag <a href="#foo?bar=baz">link</a naviagtes only to #foo, which to a newcomer would be unexpected behavior. With the ride of "deep-linking" in mobile applications, it makes more sense to leave the hash as navigated rather than modifying it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment