Bootstrap: Events on .dropdown-toggle are only triggered once

Created on 25 Jan 2019  路  3Comments  路  Source: twbs/bootstrap

$(document).on('click', 'a', function(){
  alert("CLICK")
})

This should trigger on every click, but when it's on a .dropdown-toggle it only works once.
I suspect there is some code in bootstrap that unbinds all events by mistake.

js v4

Most helpful comment

Has there been any investigation as to know why the event propagation is stopped? I'm trying to rely on the button click event to perform some actions too and it only works the first time the button is clicked, which is annoying as now I need to register event handlers for the click event and show.bs.dropdown and hide.bs.dropdown instead of only the first one.

All 3 comments

That's true we call .stopPropagation() but currently I don't know why 馃

Has there been any investigation as to know why the event propagation is stopped? I'm trying to rely on the button click event to perform some actions too and it only works the first time the button is clicked, which is annoying as now I need to register event handlers for the click event and show.bs.dropdown and hide.bs.dropdown instead of only the first one.

this still seems to be an issue.
i cant for the life of me figure out why its a good idea to stop Propagation in this.

.on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function(e) {
e.stopPropagation();
});

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MrCsabaToth picture MrCsabaToth  路  3Comments

knownasilya picture knownasilya  路  3Comments

iklementiev picture iklementiev  路  3Comments

eddywashere picture eddywashere  路  3Comments

IamManchanda picture IamManchanda  路  3Comments