bootstrap4-toggle
bootstrap4-toggle copied to clipboard
OnClick event never fires !
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
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')});