首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >自举模式-关闭模式,刷新模式,重新启动模式

自举模式-关闭模式,刷新模式,重新启动模式
EN

Stack Overflow用户
提问于 2022-10-11 16:11:09
回答 1查看 23关注 0票数 1

我正在努力升级一个图片库(标准的图片库不允许我需要的一些照片的文本数量)。一切正常,但当我在按钮上运行代码以导航到上一张或下一张照片时,模式关闭,更新新照片的模式的代码运行,但该模式不会重新打开。但是,如果我在关闭该模式后插入一个警报,则一切都按预期的方式工作。

我尝试过很多事情,包括写到控制台,但这不会影响任何事情。在上面的示例中,我尝试了一个“睡眠”函数,但是它在模式关闭之前执行,因此没有产生积极的效果(除了等待模式关闭)。注释掉上面代码中的警报将运行"open_gallery_form()“中的代码,但是显示模式的代码不会触发。

代码语言:javascript
复制
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.
代码语言:javascript
复制
<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>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-11 19:49:41

根据伊舍伍德的评论意见如下:

代码语言:javascript
复制
setTimeout(() => {  open_gallery_form(event_code, ep_id) }, "1000");

工作延迟,然后调用函数,1秒的延迟似乎就足够了。我认为这件事已经完成,而且很有效。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74031123

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档