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 the die
() 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 .die it'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.

Reply via email to