I have 2 buttons Submit, which posts the data and gets back validation errors from the server, and a Cancel which calls window.history.back()
.
I click Submit X number of times (post es/stays on the page because of validation errors from server)
On Chrome I need to click Cancel X times to go back to the previous page.
On Mozilla I only need to click Cancel once.
I guess Chrome counts the POST requests/direct backs in the history but Mozilla does not. I am not familiar with how that works or jquery. Is there something I can do to fix this?
EDIT: Going to hard code the urls in the link as suggested. Will e back later to try and see if I can do this by sending the referring page url to the edit form to load into the Cancel button, if no one beats me to it.
…
{{ Form::submit('Create', array('class'=>'btn btn-info')) }}
<a href="{{ URL::previous() }}" class="back btn btn-danger">Cancel</a>
{{ Form::close() }}
<script type="text/javascript">
$(document).ready(function() {
$('a.back').click(function(e) {
e.preventDefault();
window.history.back();
return false;
});
});
…
</script>
I have 2 buttons Submit, which posts the data and gets back validation errors from the server, and a Cancel which calls window.history.back()
.
I click Submit X number of times (post es/stays on the page because of validation errors from server)
On Chrome I need to click Cancel X times to go back to the previous page.
On Mozilla I only need to click Cancel once.
I guess Chrome counts the POST requests/direct backs in the history but Mozilla does not. I am not familiar with how that works or jquery. Is there something I can do to fix this?
EDIT: Going to hard code the urls in the link as suggested. Will e back later to try and see if I can do this by sending the referring page url to the edit form to load into the Cancel button, if no one beats me to it.
…
{{ Form::submit('Create', array('class'=>'btn btn-info')) }}
<a href="{{ URL::previous() }}" class="back btn btn-danger">Cancel</a>
{{ Form::close() }}
<script type="text/javascript">
$(document).ready(function() {
$('a.back').click(function(e) {
e.preventDefault();
window.history.back();
return false;
});
});
…
</script>
Share
Improve this question
edited Dec 31, 2014 at 15:19
Howard Renollet
4,7392 gold badges25 silver badges31 bronze badges
asked Dec 30, 2014 at 20:53
PhilPhil
2,24611 gold badges36 silver badges58 bronze badges
3
- If you don't care about preserving the data why don't you just redirect wherever you want the user to go upon canceling? – Hanlet Escaño Commented Dec 30, 2014 at 21:28
- At the start of the day, I was convinced that I would need to call the edit form from different places... but now I think I don't so! Thanks! – Phil Commented Dec 30, 2014 at 21:35
-
I've never used it myself, but you may be able to use
return Redirect::back()
to return the user to where ever it was that they came from. – user1669496 Commented Dec 30, 2014 at 21:55
1 Answer
Reset to default 5In case you ever need to use back again, the safe cross-browser option was to use history.go(-1);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744800158a4594442.html
评论列表(0条)