我正在升級照片庫(標準的照片庫不允許我需要一些照片的文字量)。一切正常,但是當我在按鈕上運行代碼以導航到上一張或下一張照片時,模態關閉,更新新照片模態的代碼運行,但模態不會重新打開。但是,如果我在關閉模式后插入警報,一切都會按預期作業。
我嘗試了各種方法,包括寫入控制臺,但這不會影響任何事情。我嘗試了一個“睡眠”功能,其中警報在上面的示例中,但它在模式關閉之前執行,所以沒有產生積極的效果(除了等待模式關閉)。注釋掉上面代碼中的警報會運行“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/[email protected]/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/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script>
uj5u.com熱心網友回復:
根據isherwood的評論如下:
setTimeout(() => { open_gallery_form(event_code, ep_id) }, "1000");
作業延遲,然后呼叫函式,1 秒的延遲似乎就足夠了。我稱這已完成并正在作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/516850.html
下一篇:行內輸入和按鈕
