1

Following is my code , where I am reloading the page on click of modal button . it working on PC , But not on Ipad.

 $(".yes_continue").off('click').click(function () {

                $("#data_variation_step1").modal("hide");
                sessionStorage.setItem("continue", 'yes');
                window.location.reload(true);
                //alert('AUEEE')


            });

Tried these too

  • setTimeout(function(){document.location.href = $(location).attr('href')},500);
  • window.location.reload();

  • location.reload();

  • $(".yes_continue").bind("click touchstart",function () {
  • $(".yes_continue").on("click touchstart tap touch",function () {

  • $(document).on("click touchstart tap", ".yes_continue", function () {

what may be the solution

Note : The modal hides , that means the click works but not the reload code ,and it does not alert too.. But alerts on PC

UPDATE: Problem is with sessionStorage.setItem("continue", 'yes');

  1. If I use private browsing on Ipad chrome. It does not reload. But if I remoe sessionStorage code then reload works.
  2. If I use non-private browsing the reload works even if I have sessionStorage code.But it does not set any value in session. So my question is now somewhat got twisted. I dont know how to store value for Ipad, Tried with localStorage too
Amar Singh
  • 5,464
  • 2
  • 26
  • 55

2 Answers2

0

Apparently this is an issue that can come up with ios browsers

Try adding this css:

cursor: pointer;

More details here: jQuery click events not working in iOS

Community
  • 1
  • 1
John Detlefs
  • 952
  • 8
  • 16
0

I've tried your code in Safari on my iPad with latest iOS version and it works just fine.

You can also try to reload it with window.location = window.location.href

btw I run a small server on my localhost with ngrok so you can try it here http://a42fc986.ngrok.io/ (will be available for a short time)

For test I've used this simple code:

<div>
    <span>window.location.reload(true)=></span>
    <button class="yes_continue_1st">Press me (button)</button>
    <span class="yes_continue_1st">Press me (span)</span>
</div>
<div>
    <span>window.location = window.location.href=></span>
    <button class="yes_continue_2nd">Press me</button>
    <span class="yes_continue_2nd">Press me (span)</span>
</div>

<script type="text/javascript">
    $(".yes_continue_1st").off('click').click(function () {
        alert("before location.reload");
        window.location.reload(true);
        alert("after location.reload");
    });

    $(".yes_continue_2nd").off('click').click(function () {
        alert("before location.href");
        window.location = window.location.href;
        alert("after location.href");
    });
</script>
Alex Pavlov
  • 150
  • 6