jquery-archive / jquery-mobile

jQuery Mobile Framework
https://jquerymobile.com
Other
9.7k stars 2.41k forks source link

HTTP redirect after form post breaks hash urls #951

Closed nuba closed 13 years ago

nuba commented 13 years ago

I have a form at http://example.com/foo/new and with the same URL for the form's action. When posting it with jquery-mobile, I get a HTTP redirect to http://example.com/foo/[some uuid]/ . What happens then is jquery-mobile installs the content of http://example.com/foo/[some uuid] under http://example.com/foo/new/#/foo/new/ , then clicking a link to come back to the form ( http://example.com/foo/new/ ) results in jquery-mobile doing nothing, as it seems it thinks it's the page already in the cache and currently being shown.

I was expecting jquery-mobile to follow the redirect, and install the retrieved content under http://example.com/foo/new/#/foo/[some uuid]/ .

Adding rel="external" and target="_blank" to the

(to force an non-ajax post, which I thought maybe would follow the HTTP redirect correctly) has no effect.

mattpepin commented 13 years ago

I have the same issue...

scottjehl commented 13 years ago

This is because the Ajax response provides no location header to tell us which url the request was redirected to. Since we have know way to find this out, we created a way to pass it to the framework manually. To do so, simply serve your redirected page with a data-url attribute already populated with the proper full hash path to that page. If a data-url is present when a page arrives, jQuery Mobile will use that instead of the url to which the the form was submitted. See bottom of this page for details: http://jquerymobile.com/test/#docs/pages/docs-pages.html

hslewis commented 13 years ago

Hi, I tried this on a3 ... it does not seem to work.

eg:

ends up with
in the DOM. Any Ideas what I could be doing wrong? Thanks, Steve