JQuery does not open Bootstrap modal on mobile(iPhone)





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







9















I have a Javascript/JQuery function which is supposed to open a bootstrap modal after an AJAX request.



This works on PC using Chrome but unfortunately it doesn't work on iPhone(Chrome/Safari)



The button:



  <button type="button" id="GetEmployees" class="btn btn-primary"  onclick="GetEmployees()">
<span class="glyphicon glyphicon-user">&nbsp;</span>Toevoegen
</button>


The function:



function GetEmployees() {
$.ajax({
type: 'post',
url: appPath + '/TimeRegistration/GetEmployees',
data: { },
success: function (response) {
if (response != null) {
alert("Load");
$("#dialog-project .modal-body").html(response);
$("#dialog-project").modal("show");
alert("open");
}
},
error: function (response) {
alert("Onbekende fout opgetreden")
}
});
}


And here is the dialog itself:



  <div id="dialog-project" class="modal fade" tabindex="-1" role="dialog" style="color: #333333;">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 id="dialog-title" class="modal-title">Aanmaken nieuwe tijdregel</h4>
</div>
<div class="modal-body">

</div>
</div>
</div>
</div>


For some reason on iPhone I get the alert "Load" but the modal isn't showing up and also the last alert is not showing up.



edit2: In order to make the buttons execute the JS at the first place I had to add:



$(document).ready(function () {
var touchEvent = 'onclick' in window ? 'click' : 'touchstart';
$('#GetEmployees').on('click touchstart', function () {
GetEmployees();
})
})









share|improve this question

























  • Does it works on firefox or edge on PC ?

    – Sylvain Attoumani
    Jan 3 at 10:42











  • @SylvainAttoumani Yes it works on Firefox as well on pc ;)

    – Falcon
    Jan 3 at 10:43











  • the thing with cursor:pointer; doesnt seem to be integrated correct, bootstrap should add cursor:pointer to the buttons, not?

    – john Smith
    Jan 3 at 11:22











  • which version of bootstrap you are using ?

    – Narendra Jadhav
    Jan 3 at 11:23











  • @NarendraJadhav Bootstrap v3, and johnSmith I think not. I can't imagine it being the problem as the JS functions are executed correctly, untill we call the modals.

    – Falcon
    Jan 3 at 11:25


















9















I have a Javascript/JQuery function which is supposed to open a bootstrap modal after an AJAX request.



This works on PC using Chrome but unfortunately it doesn't work on iPhone(Chrome/Safari)



The button:



  <button type="button" id="GetEmployees" class="btn btn-primary"  onclick="GetEmployees()">
<span class="glyphicon glyphicon-user">&nbsp;</span>Toevoegen
</button>


The function:



function GetEmployees() {
$.ajax({
type: 'post',
url: appPath + '/TimeRegistration/GetEmployees',
data: { },
success: function (response) {
if (response != null) {
alert("Load");
$("#dialog-project .modal-body").html(response);
$("#dialog-project").modal("show");
alert("open");
}
},
error: function (response) {
alert("Onbekende fout opgetreden")
}
});
}


And here is the dialog itself:



  <div id="dialog-project" class="modal fade" tabindex="-1" role="dialog" style="color: #333333;">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 id="dialog-title" class="modal-title">Aanmaken nieuwe tijdregel</h4>
</div>
<div class="modal-body">

</div>
</div>
</div>
</div>


For some reason on iPhone I get the alert "Load" but the modal isn't showing up and also the last alert is not showing up.



edit2: In order to make the buttons execute the JS at the first place I had to add:



$(document).ready(function () {
var touchEvent = 'onclick' in window ? 'click' : 'touchstart';
$('#GetEmployees').on('click touchstart', function () {
GetEmployees();
})
})









share|improve this question

























  • Does it works on firefox or edge on PC ?

    – Sylvain Attoumani
    Jan 3 at 10:42











  • @SylvainAttoumani Yes it works on Firefox as well on pc ;)

    – Falcon
    Jan 3 at 10:43











  • the thing with cursor:pointer; doesnt seem to be integrated correct, bootstrap should add cursor:pointer to the buttons, not?

    – john Smith
    Jan 3 at 11:22











  • which version of bootstrap you are using ?

    – Narendra Jadhav
    Jan 3 at 11:23











  • @NarendraJadhav Bootstrap v3, and johnSmith I think not. I can't imagine it being the problem as the JS functions are executed correctly, untill we call the modals.

    – Falcon
    Jan 3 at 11:25














9












9








9


1






I have a Javascript/JQuery function which is supposed to open a bootstrap modal after an AJAX request.



This works on PC using Chrome but unfortunately it doesn't work on iPhone(Chrome/Safari)



The button:



  <button type="button" id="GetEmployees" class="btn btn-primary"  onclick="GetEmployees()">
<span class="glyphicon glyphicon-user">&nbsp;</span>Toevoegen
</button>


The function:



function GetEmployees() {
$.ajax({
type: 'post',
url: appPath + '/TimeRegistration/GetEmployees',
data: { },
success: function (response) {
if (response != null) {
alert("Load");
$("#dialog-project .modal-body").html(response);
$("#dialog-project").modal("show");
alert("open");
}
},
error: function (response) {
alert("Onbekende fout opgetreden")
}
});
}


And here is the dialog itself:



  <div id="dialog-project" class="modal fade" tabindex="-1" role="dialog" style="color: #333333;">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 id="dialog-title" class="modal-title">Aanmaken nieuwe tijdregel</h4>
</div>
<div class="modal-body">

</div>
</div>
</div>
</div>


For some reason on iPhone I get the alert "Load" but the modal isn't showing up and also the last alert is not showing up.



edit2: In order to make the buttons execute the JS at the first place I had to add:



$(document).ready(function () {
var touchEvent = 'onclick' in window ? 'click' : 'touchstart';
$('#GetEmployees').on('click touchstart', function () {
GetEmployees();
})
})









share|improve this question
















I have a Javascript/JQuery function which is supposed to open a bootstrap modal after an AJAX request.



This works on PC using Chrome but unfortunately it doesn't work on iPhone(Chrome/Safari)



The button:



  <button type="button" id="GetEmployees" class="btn btn-primary"  onclick="GetEmployees()">
<span class="glyphicon glyphicon-user">&nbsp;</span>Toevoegen
</button>


The function:



function GetEmployees() {
$.ajax({
type: 'post',
url: appPath + '/TimeRegistration/GetEmployees',
data: { },
success: function (response) {
if (response != null) {
alert("Load");
$("#dialog-project .modal-body").html(response);
$("#dialog-project").modal("show");
alert("open");
}
},
error: function (response) {
alert("Onbekende fout opgetreden")
}
});
}


And here is the dialog itself:



  <div id="dialog-project" class="modal fade" tabindex="-1" role="dialog" style="color: #333333;">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 id="dialog-title" class="modal-title">Aanmaken nieuwe tijdregel</h4>
</div>
<div class="modal-body">

</div>
</div>
</div>
</div>


For some reason on iPhone I get the alert "Load" but the modal isn't showing up and also the last alert is not showing up.



edit2: In order to make the buttons execute the JS at the first place I had to add:



$(document).ready(function () {
var touchEvent = 'onclick' in window ? 'click' : 'touchstart';
$('#GetEmployees').on('click touchstart', function () {
GetEmployees();
})
})






javascript jquery ios






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 12:07







Falcon

















asked Jan 3 at 10:37









FalconFalcon

338114




338114













  • Does it works on firefox or edge on PC ?

    – Sylvain Attoumani
    Jan 3 at 10:42











  • @SylvainAttoumani Yes it works on Firefox as well on pc ;)

    – Falcon
    Jan 3 at 10:43











  • the thing with cursor:pointer; doesnt seem to be integrated correct, bootstrap should add cursor:pointer to the buttons, not?

    – john Smith
    Jan 3 at 11:22











  • which version of bootstrap you are using ?

    – Narendra Jadhav
    Jan 3 at 11:23











  • @NarendraJadhav Bootstrap v3, and johnSmith I think not. I can't imagine it being the problem as the JS functions are executed correctly, untill we call the modals.

    – Falcon
    Jan 3 at 11:25



















  • Does it works on firefox or edge on PC ?

    – Sylvain Attoumani
    Jan 3 at 10:42











  • @SylvainAttoumani Yes it works on Firefox as well on pc ;)

    – Falcon
    Jan 3 at 10:43











  • the thing with cursor:pointer; doesnt seem to be integrated correct, bootstrap should add cursor:pointer to the buttons, not?

    – john Smith
    Jan 3 at 11:22











  • which version of bootstrap you are using ?

    – Narendra Jadhav
    Jan 3 at 11:23











  • @NarendraJadhav Bootstrap v3, and johnSmith I think not. I can't imagine it being the problem as the JS functions are executed correctly, untill we call the modals.

    – Falcon
    Jan 3 at 11:25

















Does it works on firefox or edge on PC ?

– Sylvain Attoumani
Jan 3 at 10:42





Does it works on firefox or edge on PC ?

– Sylvain Attoumani
Jan 3 at 10:42













@SylvainAttoumani Yes it works on Firefox as well on pc ;)

– Falcon
Jan 3 at 10:43





@SylvainAttoumani Yes it works on Firefox as well on pc ;)

– Falcon
Jan 3 at 10:43













the thing with cursor:pointer; doesnt seem to be integrated correct, bootstrap should add cursor:pointer to the buttons, not?

– john Smith
Jan 3 at 11:22





the thing with cursor:pointer; doesnt seem to be integrated correct, bootstrap should add cursor:pointer to the buttons, not?

– john Smith
Jan 3 at 11:22













which version of bootstrap you are using ?

– Narendra Jadhav
Jan 3 at 11:23





which version of bootstrap you are using ?

– Narendra Jadhav
Jan 3 at 11:23













@NarendraJadhav Bootstrap v3, and johnSmith I think not. I can't imagine it being the problem as the JS functions are executed correctly, untill we call the modals.

– Falcon
Jan 3 at 11:25





@NarendraJadhav Bootstrap v3, and johnSmith I think not. I can't imagine it being the problem as the JS functions are executed correctly, untill we call the modals.

– Falcon
Jan 3 at 11:25












1 Answer
1






active

oldest

votes


















0














I am also faced a same issue. I was fixed by following code.



$( "#code" ).on('shown', function(){
$('body').css('position','fixed');
});


In IOS browser position has issue and it take fixed position.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54020603%2fjquery-does-not-open-bootstrap-modal-on-mobileiphone%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I am also faced a same issue. I was fixed by following code.



    $( "#code" ).on('shown', function(){
    $('body').css('position','fixed');
    });


    In IOS browser position has issue and it take fixed position.






    share|improve this answer




























      0














      I am also faced a same issue. I was fixed by following code.



      $( "#code" ).on('shown', function(){
      $('body').css('position','fixed');
      });


      In IOS browser position has issue and it take fixed position.






      share|improve this answer


























        0












        0








        0







        I am also faced a same issue. I was fixed by following code.



        $( "#code" ).on('shown', function(){
        $('body').css('position','fixed');
        });


        In IOS browser position has issue and it take fixed position.






        share|improve this answer













        I am also faced a same issue. I was fixed by following code.



        $( "#code" ).on('shown', function(){
        $('body').css('position','fixed');
        });


        In IOS browser position has issue and it take fixed position.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 13 at 6:07









        bimal sharmabimal sharma

        1066




        1066
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54020603%2fjquery-does-not-open-bootstrap-modal-on-mobileiphone%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith