引导模式-关闭模式、刷新模式、重新打开模式



我正在升级照片库(标准的照片库不允许我为一些照片提供所需的文本量(。一切正常,但当我在按钮上运行代码以导航到上一张或下一张照片时,模态关闭,为新照片更新模态的代码运行,但模态不会重新打开。但是,如果我在关闭模态后插入一个警告,一切都会按预期进行。

我试过很多方法,包括在控制台上写东西,但这不会影响任何事情。我尝试了一个";睡眠;函数,其中警报在上面的示例中,但它在模态关闭之前执行,因此没有产生积极影响(除了等待模态关闭(。注释掉上面代码中的警报运行"0"中的代码;open_gallery_form((";,但是显示模态的代码不会激发。

function nav_button_click(event_code, ep_id) {
// close current version of modal form:
$("#imageModal").modal('hide');
// the form won't re-open without this which is frustrating ...
// tried a "sleep" routine but that fires before the form is closed (above),
// so is useless ... 
// console.log("navigating"); console log doesn't do anything
alert("navigating"); // please don't change the code
// call code to refresh with new image and text, updated buttons, etc.
// and display modal
open_gallery_form(event_code, ep_id);
}
// More code here, please.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
More markup here, please.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script>

根据isherwood的评论如下:

setTimeout(() => {  open_gallery_form(event_code, ep_id) }, "1000");

工作来延迟,然后调用函数,1秒的延迟似乎就足够了。我认为这已经完成并正在发挥作用。

最新更新