亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

關閉另一個模式時打開模式的問題

關閉另一個模式時打開模式的問題

一只斗牛犬 2023-05-25 18:19:48
這是我的場景。我有一個模式(模式 A),在頁腳中有 2 個按鈕:保存并關閉。當我點擊“保存”按鈕時,我需要關閉模態 A 并打開模態 B,它適用于以下代碼:模態A:<div class="modal fade" tabindex="-1" role="dialog" id="modalAddressees">    <div class="modal-dialog modal-lg" role="document">        <div class="modal-content">            <div class="modal-header">                <h5 class="modal-title">Select Addresses</h5>                <button type="button" class="close" data-dismiss="modal" aria-label="Close">                    <span aria-hidden="true">×</span>                </button>            </div>            <div class="modal-body">                [....]            </div>            <div class="modal-footer bg-whitesmoke br">                <button type="button" id="saveBtn" class="btn btn-primary">Save</button>                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>            </div>        </div>    </div></div>Java腳本:$().ready(function () {    $("#saveBtn").on('click', function () {        $('#modalAddressees').modal('hide')        $('#modalAddressees').on('hidden.bs.modal', function () {            $('#modalNewAddress').modal('show');        })    });});但是在我關閉模態 B 并再次打開模態 A 之后,如果我單擊關閉按鈕(關閉它)它會再次打開模態 B,為什么?在我的 Javascript 中,我選擇僅在單擊“保存”按鈕時打開模式 B,而不是關閉按鈕。請問你能幫幫我嗎?這里我的測試有同樣的錯誤:https ://jsfiddle.net/swim89/xso0jw9k/2/
查看完整描述

3 回答

?
慕蓋茨4494581

TA貢獻1850條經驗 獲得超11個贊

為了解決這個問題,我改變了我的代碼是這樣的:


$().ready(function () {

    $("#saveBtn").on('click', function () {

        $('#modalAddressees').modal('hide');

        $('#modalNewAddress').modal('show');

    });

});


查看完整回答
反對 回復 2023-05-25
?
烙印99

TA貢獻1829條經驗 獲得超13個贊

在隱藏的 bs 模態 id: modalAddAddress 顯示模態 id: modalNewAddress


$('#modalAddressees').on('hidden.bs.modal', function () {

    $('#modalNewAddress').modal('show');

 })

似乎它像你寫的那樣工作。


查看完整回答
反對 回復 2023-05-25
?
心有法竹

TA貢獻1866條經驗 獲得超5個贊

Javascript

$().ready(function () {

    const modalA = $('#modalAddressees');

    $("#saveBtn").on('click', function () {

        modalA.modal('hide')

        modalA.off('hidden.bs.modal').on('hidden.bs.modal', function () {

            modalA.modal('show');

        })

    });

});

或者


$().ready(function () {

    const modalA = $('#modalAddressees');

    modalA.on('hidden.bs.modal', function () {

        modalA.modal('show');

    });

    $("#saveBtn").on('click', function () {

        modalA.modal('hide');

    });

});


查看完整回答
反對 回復 2023-05-25
  • 3 回答
  • 0 關注
  • 171 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號