I want to remove a class from a button as soon as my modal opens. I'm having trouble doing this because I don't know how to check when the modal is opened. I'm using uikit which gives me the following examples:
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.");
}
});
My modal is the following:
<div id="offerModal" class="uk-modal">
<div class="uk-modal-dialog uk-modal-dialog-blank">...</div>
</div>
Something like this should do the trick for you:
$('.modalSelector').on({
'show.uk.modal': function(){
console.log("Modal is visible.");
$('.btn').removeClass('abc');
},
'hide.uk.modal': function(){
console.log("Element is not visible.");
}
});