[英]Close jquery modal
I'm importing Jquery Modal from these two links (js and css)我从这两个链接(js和css)导入Jquery Modal
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.css" />
I've added the following html code inside the body我在正文中添加了以下 html 代码
<button onclick="load();" class="btn btn-primary">
<span class="fa fa-icon fa-filter"></span>
Filtrar
</button>
<div id="loadingModal" class="" style="display:none">
Cargando
</div>
and the following is in a js file以下是在一个js文件中
function load() {
openLoadingModal();
doSomething();
closeModal();
}
function openLoadingModal(e) {
$("#loadingModal").modal("show");
var count = 0;
var points = "";
var intervalId = window.setInterval(function(){
count++;
$("#loadingModal").text("Cargando" + ".".repeat(count % 3 + 1));
}, 1000);
return intervalId;
}
With this, the modal opens as I expect.有了这个,模态就像我预期的那样打开。 The thing is that I want to close the modal when this ends.问题是我想在结束时关闭模式。 But the solutions I've found didn't work.但是我找到的解决方案不起作用。 I tried the following:我尝试了以下方法:
$("#loadingModal").modal("close");
$("#loadingModal").modal().close();
$("#loadingModal").modal().close;
$("#loadingModal").modal("toggle");
$("#loadingModal").modal().toggle();
None of this closes the modal as it should (maybe hides the modal, but not all of it, since there is a black screen)这些都没有按应有的方式关闭模态(可能隐藏了模态,但不是全部,因为有黑屏)
I think this shouldn't be this hard, but every link I get in tells me to do one of this我认为这不应该这么难,但是我进入的每个链接都告诉我做一个
Thanks谢谢
If there is only one modal on the page, use this:如果页面上只有一个模式,请使用:
$.modal.close();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.