Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Self-submitting form adds self to history again #3226

Closed
kanetik opened this issue Dec 6, 2011 · 7 comments
Closed

Self-submitting form adds self to history again #3226

kanetik opened this issue Dec 6, 2011 · 7 comments

Comments

@kanetik
Copy link

kanetik commented Dec 6, 2011

I am using MS MVC3, and I have a page that contains a form which submits to itself. Upon submitting, the page is added to history, so that the back button now has to be clicked 2 times to get back to the prior page.

@kanetik
Copy link
Author

kanetik commented Dec 6, 2011

To see this problem, use these 2 page's HTML. load Page1, click "Add Item", hit "Save", and then try to get back to the initial page. You have to hit back 2 times.

Page 1:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta http-equiv="Pragma" content="no-cache" />
<link href="//code.jquery.com/mobile/1.0/jquery.mobile-1.0.css" rel="stylesheet" type="text/css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js" type="text/javascript"></script>
<script src="//code.jquery.com/mobile/1.0/jquery.mobile-1.0.js" type="text/javascript"></script>
</head>
<body>
<div data-role="page" data-title="Test" id="salesWorkbench" data-add-back-btn="true">
<div data-role="content">
<div class="waitlistcontainer">
<h3>Wait List</h3>
<a href="test2.html" data-role="button">Add Item</a>
</div>
</div>
</div>
</div>
</body>
</html>

Page 2:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta http-equiv="Pragma" content="no-cache" />
<link href="//code.jquery.com/mobile/1.0/jquery.mobile-1.0.css" rel="stylesheet" type="text/css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js" type="text/javascript"></script>
<script src="//code.jquery.com/mobile/1.0/jquery.mobile-1.0.js" type="text/javascript"></script>
</head>
<body>
<div data-role="page" data-title="Test Dialog" id="salesWorkbenchDialog" data-add-back-btn="true">
<div data-role="content">
<div class="waitlistcontainer">
<h3>Wait List Detail</h3>
<form>
<input type="text">
<button id="saveWaiting" data-inline="true">Save</button>
<a href="#" data-role="button" data-rel="back" data-inline="true">Cancel</a>
</form>
</div>
</div>
</div>
</body>
</html>

@tec27
Copy link

tec27 commented Dec 6, 2011

That's what happens without jQuery Mobile as well, its not a bug.

Your button here is causing a request to test2.html?, so the chain of HTTP 200 responses is:
test1.html -> test2.html -> test2.html?

Thus the first back button press takes you to test2.html, the next to test1.html

If you handle your saving through AJAX, you'll just want to prevent that button from actually causing the request from the server.

@kanetik
Copy link
Author

kanetik commented Dec 6, 2011

Sorry, this response was thinking about another issue I'd been discussing, which is very similar to this one... I'll tweak my response accordingly:

Well, if I were doing this on a non-JQM site, I would write it so that it does the request via an AJAX call. I'm purposely NOT writing my own AJAX scripts (or at least, I WAS), presuming that "the JQM way" is to treat things more linearly, and let it manage the AJAXification of the flow.

As I'm learning more, though, I'm coming to realize that I cannot presume "the JQM way" is as simple as that. No worries, I'm just plowing ahead, and will come up with a way to deal with it.

@tec27
Copy link

tec27 commented Dec 6, 2011

Well, "the JQM way" would be to make navigation as similar to non-AJAX as possible, while giving you all the transitions, styling, and performance enhancements that come from doing the AJAX request. If your goal is to perform an AJAX save that happens in the background and have a response that doesn't act as an actual page, you should really just be doing that as you normally would without jQuery Mobile.

@kanetik
Copy link
Author

kanetik commented Dec 6, 2011

I don't disagree - but my team lead does (though he's stated that he'd be
open to re-thinking that if need be, and I think need be :)

Thanks!

On Tue, Dec 6, 2011 at 4:04 PM, Travis Collins <
reply@reply.github.com

wrote:

Well, "the JQM way" would be to make navigation as similar to non-AJAX as
possible, while giving you all the transitions, styling, and performance
enhancements that come from doing the AJAX request. If your goal is to
perform an AJAX save that happens in the background and have a response
that doesn't act as an actual page, you should really just be doing that as
you normally would without jQuery Mobile.


Reply to this email directly or view it on GitHub:
#3226 (comment)

@toddparker
Copy link
Contributor

So is this closable? Not sure what to do with this one.

@kanetik kanetik closed this as completed Dec 14, 2011
@kanetik
Copy link
Author

kanetik commented Dec 14, 2011

There is ongoing discussion going on (I think) for a similar "bug" (#3227), so this is most likely redundant. Closing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants