0

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>
dbn
  • 458
  • 5
  • 12
unconditionalcoder
  • 723
  • 1
  • 13
  • 25

1 Answers1

2

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.");
    }
});
bmcculley
  • 2,048
  • 1
  • 14
  • 17