打开模态时做一些事情

Do something when modal is opened

我想在模式打开后立即从按钮中删除 class。我在执行此操作时遇到了麻烦,因为我不知道如何检查模式何时打开。我正在使用 uikit,它为我提供了以下示例:

var modal = UIkit.modal(".modalSelector");

if ( modal.isActive() ) {
    modal.hide();
} else {
    modal.show();
}

$('.modalSelector').on({

    'show.uk.modal': function(){
        console.log("Modal is visible.");
    },

    'hide.uk.modal': function(){
        console.log("Element is not visible.");
    }
});

我的模态如下:

<div id="offerModal" class="uk-modal">
    <div class="uk-modal-dialog uk-modal-dialog-blank">...</div>
</div>

像这样的东西应该对你有用:

$('.modalSelector').on({

    'show.uk.modal': function(){
        console.log("Modal is visible.");
        $('.btn').removeClass('abc');
    },

    'hide.uk.modal': function(){
        console.log("Element is not visible.");
    }
});