Skip to content
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

Self-submitting form adds self to history again #3226

Closed
jkane001 opened this Issue Dec 6, 2011 · 7 comments

Comments

Projects
None yet
3 participants
@jkane001
Copy link

jkane001 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.

@jkane001

This comment has been minimized.

Copy link
Author

jkane001 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

This comment has been minimized.

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.

@jkane001

This comment has been minimized.

Copy link
Author

jkane001 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

This comment has been minimized.

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.

@jkane001

This comment has been minimized.

Copy link
Author

jkane001 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

This comment has been minimized.

Copy link
Contributor

toddparker commented Dec 12, 2011

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

@jkane001 jkane001 closed this Dec 14, 2011

@jkane001

This comment has been minimized.

Copy link
Author

jkane001 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 join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.