bootstrap4-toggle icon indicating copy to clipboard operation
bootstrap4-toggle copied to clipboard

OnClick event never fires !

Open Mina-R-Meshriky opened this issue 4 years ago • 1 comments

Only the Change event is firing correctly, but the on click event never fires.

 <input title="Activation status" type="checkbox" class="de-activate" checked
                               data-toggle="toggle" data-size="small" data-onstyle="success"
                               data-on="Activated" data-off="Deactivated">
 $('.de-activate').click( (e)=>{
            let el = $(e.target);
            console.log(el);
        });

I need the click event, since I want to show a warning before changing the state of the toggle

Mina-R-Meshriky avatar Apr 21 '20 09:04 Mina-R-Meshriky

I've just run into this problem, managed to work around it by enclosing the input in a div and then using a delegated click event on .toggle for that div, this picks it so I can do a check first.

<div class="toggle-div"><input class="toggle-option" type="checkbox" data-toggle="toggle"></div>

$('.toggle-div').on('click', '.toggle', function(e) { e.preventDefault(); e.stopPropagation(); console.log('clicked')});

jonmnoj avatar Apr 22 '20 09:04 jonmnoj