简体   繁体   English

Bootstrap Twitter关闭模式重定向

[英]Bootstrap Twitter Close Modal Redirect

I have an URL: 我有一个网址:

'/toto/errorSubmitForm/'

I have a modal with close button who redirect in an other URL when I click on the close button with this code 我有一个带关闭按钮的模式,当我使用此代码单击关闭按钮时,该链接会重定向到另一个URL

function clickCloseModal() {
   $('#closeModal').click(function(evt){
     evt.preventDefault();
        window.location.href = "/toto/";
   });
}

But when I click outside of the modal, the I leave the modal, then I search to redirect it too. 但是,当我在模态之外单击时,我离开了模态,然后我也搜索了重定向它。 I try to do this when I change the ID like that but didnt work. 当我像这样更改ID但没有用时,我会尝试这样做。

var modal = document.getElementById('myModal');

window.onclick = function(event) {
   if (event.target == modal) {
      window.location.href = "/toto/";
   }
}

I give you the start of my modal 我给你我模态的开始

<div id="myModal" class="modal fade" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">

You should handle the event on closing modal so that you can redirect to the specified url: 您应该在关闭模式时处理事件,以便可以重定向到指定的url:

$('#myModal').on('hidden.bs.modal', function () {
  window.location.href = "/toto/";
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM