In these two items i call a specific function
$('.item >li> div').click(function (e) {
$('.item .time').live('mousedown', function (e) {
e.stopPropagation();
In opera, firefox this works fine. In chrome when i click the time div my function runs twice instead of once. In jquerys Additional Notes it mentions this
Since the .live() method handles events once they have propagated to the top of the document, it is not possible to stop propagation of live events. Similarly, events handled by .delegate() will always propagate to the element to which they are delegated; event handlers on any elements below it will already have been executed by the time the delegated event handler is called.
ok fine, but how do i stop my function from being run twice? also if i remove the line stopPropagation firefox and opera will开发者_如何学C have the same problem.
using jquery 1.4.4
click
and mousedown
are distinct events, stopping the propagation of one won't affect the other in any way. Also, live events fire after normal events, so you would have to call stopPropagation
in the normal event handler, anyway.
I cheated and just checked with jquery what browser it is and if its chrome i just return. It works perfect ATM.
If it works with the if statement it would likely work if you removed the if statement and just returned regardless...
精彩评论