bootstrap modal issue in chrome

2019-05-23 18:15发布

问题:

I have a bootstrap modal in my asp.net mvc code that it's body bind in runtime. first time I click on the some button and modal work good (body return from controller by jquery ajax).

then must change model’s body dynamically , it works good too(by jquery Ajax and json). then I close modal. second time I click on some button , modal work but with problem . the problem is scrollbar of modal's body is enable but not working , like that the modal is lock . this problem is in chrome , but in IE I have not that. my code for modal :

...
success: function (response) {
$('#myModal').html(response);
$('#myModal').modal({ show: true, backdrop: false, keyboard: false });
...

I change css : overflow:hidden and position:fix but it's not work

回答1:

the only suggestion is click F12 in chrome and try to debug. but my initial guess is that some CSS standard is diff with two explorer.



回答2:

I got the same problem. I found the solution, but I don't know How It Works. The solution is, add some jquery codes I wrote below.

  $('.modal').bind('shown.bs.modal', function () {
    $(".modal").css("overflow-y", "scroll");
  });
  $('.modal').bind('hide.bs.modal', function () {
    $(".modal").css("overflow-y", "auto");
  });

Good Luck!