created a ticket: http://dev.jquery.com/ticket/4894
On Jul 11, 1:57 pm, Leeoniya <leeon...@gmail.com> wrote: > yeah, that seems like a bug. here is a more concise version showing > the bug and a non-delegation based version: > > // without event delegation -- works fine > $(function() { > $("#b").click(function() { > $("#a span").unbind("click"); > return false; > }); > > $("#a span").hover( > function() {$(this).addClass("high");}, > function() {$(this).removeClass("high");} > ).click(function() { > $(this).append(" He. "); > }); > > }); > > /* with event delegation - .die("click") kills all live events > $(function() { > $("#b").live("click", function() { > $("#a span").die("click"); > return false; > }); > > $("#a span") > .live("mouseover", function() {$(this).addClass("high");}) > .live("mouseout", function() {$(this).removeClass("high");}) > .live("click", function() {$(this).append(" He. ");});}); > > */ > > On Jul 11, 11:28 am, Pau Taw <pau...@gmail.com> wrote: > > > Finally I've isolated the problem in a little example. I'll post the > > code below. > > > As I could test if you bind the events to a child element then thedie > > () removes all events bound to that. In the example I just bind > > mouseover, mouseout and click to a span inside of a paragraph. Then > > remove the click event... and all events are removed. > > > Maybe it's that i'm making a mistake, i've been working only a month > > with jquery. > > > ¿Any idea? Thanks. > > > Example code: > > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es"> > > > <head> > > <script type="text/javascript" src="http://ajax.googleapis.com/ajax/ > > libs/jquery/1.3/jquery.min.js"></script> > > <script type="text/javascript"> > > <!-- > > $(document).ready(function() { > > $("#b").bind("click", function() { > > $("#a span").die("click"); > > }); > > > }); > > > $("#a span").live("mouseover", function() { > > $(this).addClass("high"); > > > }); > > > $("#a span").live("mouseout", function() { > > $(this).removeClass("high"); > > > }); > > > $("#a span").live("click", function() { > > $(this).append(" He. "); > > > }); > > > //--> > > </script> > > <style type="text/css"> > > .high { > > background:#FF0;} > > > </style> > > > </head> > > <body> > > > <p id="a"><span>This has a over highlight style and event 'click'.</ > > span></p> > > > <p><a id="b" href="#">Click here to erase the click event in the last > > paragraph's inner span</a></p> > > > </body> > > </html> > > > On 8 jul, 04:47, James <james.gp....@gmail.com> wrote: > > > > Using jQuery 1.3.2, I've tested this on my own very basic set up and > > > it's working as expected (only the click event is unbinded). > > > There's something else going on in your code. Could you provide more > > > information? Such as your HTML. > > > > On Jul 7, 1:59 pm, Pau Taw <pau...@gmail.com> wrote: > > > > > Hi all. I've the next code: > > > > > $("#box").live("mouseover", function(){ $(this).addClass > > > > ("highlight"); }); > > > > $("#box").live("mouseout", function(){ $(this).removeClass > > > > ("highlight"); }); > > > > > $("#box").live("click", function(){ alert("Hi"); }); > > > > > $("#erase").bind('click', function() { > > > > $("#box").die("click"); > > > > > }); > > > > > So, what I want to do is simple, I asign mouseover and mouseout > > > > "highlight" effect to a div. And if you click the div then you get an > > > > alert. This works nice. > > > > > Then, if you click a link with id="erase", the click event bound to > > > > the #box must be deleted. With .dieit's done nicely but, this is the > > > >rarebehaviour, the other live events are unbound too (mouseover, and > > > > mouseout). > > > > > The Docs says that using this sintax .die("click") then only the click > > > > events must be unbound. ¿I am wrong? > > > > > Thanks.