How to reload page on closing a Bootstrap 3 modal

后端 未结 3 889
后悔当初
后悔当初 2021-02-01 01:56

My aim is to get the page to reload when a Bootstrap modal is closed. The user can close the modal by clicking on the close button or icon or by clicking away from the modal.

相关标签:
3条回答
  • 2021-02-01 02:48

    You can bind the event to reload page on click of close:

    $('#myModal').on('hidden.bs.modal', function () {
     location.reload();
    })
    

    Demo

    0 讨论(0)
  • 2021-02-01 02:51

    try this with your button:

    onclick="javascript:window.location.reload()"
    

    full button:

    <button type="button" onclick="javascript:window.location.reload()" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    

    example: http://jsfiddle.net/Valtos/52VtD/2288/embedded/result/

    0 讨论(0)
  • 2021-02-01 02:55
    $('#myModal').on('hidden', function () {
      document.location.reload();
    })
    

    Demo

    0 讨论(0)
提交回复
热议问题