StopPropagation does not work in chrome + live mode

In these two elements, I call a specific function

$('.item >li> div').click(function (e) {
$('.item .time').live('mousedown', function (e) {
     e.stopPropagation();

In opera firefox, this works great. In chrome, when I click the div time, my function runs twice, not once. In jquerys Additional notes it mentions

Since the .live () method handles events when they propagate to the top of the document, it is not possible to stop the distribution of live events. Similarly, events handled by .delegate () will always propagate to the element by which they are delegated; event handlers on any elements below this will have already been executed by the time the delegated event handler.

Ok, but how can I stop my function from running twice? also, if I delete the stopPropagation line, firefox and opera will have the same problem.

using jquery 1.4.4

+3
source share
2 answers

clickand mousedown- these are different events, the cessation of the distribution of one will not affect the other. Also, live events fire after ordinary events, so you have to call stopPropagationin a regular event handler.

+2
source

I cheated and just checked with jquery which browser it is and if its chrome I just return it. He works great at an ATM.

If it works with an if statement, it will most likely work if you deleted the if statement and just came back independently ...

0

Source: https://habr.com/ru/post/1774646/


All Articles