Hi Lea,

try a look at the API documentation: 
http://www.prototypejs.org/api/event/stopObserving
(you exactly do what is wrong !!)

Because you should do:

myTestClass.myCallback=this.clickHandler.bindAsEventListener(this);

myTestClass.prototype.initEvents = function()
{
   var myDiv1 = $('exampleDiv1');
   myDiv1.observe('click',myTestClass.myCallback);
}

And to stop event observe:

myTestClass.prototype.clearEvents = function()
{
   var myDiv1 = $('exampleDiv1');
   myDiv1.stopObserving('click',myTestClass.myCallback);
}

But we are from the original question which is if we could
stopObserving all event from one element?
The response is NO (otherwise, let me know, it save a lot of time and
efforts sometime).

--
david



On Sep 2, 8:41 pm, Kruncher <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have just found out about the Prototype framework and am somewhat
> impressed by how much simpler it makes things. I have found that using
> the observe and stopObserving functions has eliminated a pretty major
> memory leak within my scripts.
>
> Below is a snippet of my code (which appears to function correctly
> with Prototype 1.6), but I just wanted to confirm that this is in fact
> correct. From the user documentation it says that the stopObserving
> method should be called in practically the same way as the observe
> method. However, I want to make sure that ALL handlers are stopped for
> a particular event of a particular element.
>
> // Called when object is initialized.
> myTestClass.prototype.initEvents = function()
> {
>    var myDiv1 = $('exampleDiv1');
>    myDiv1.observe('click',
> myTestClass.clickHandler.bindAsEventListener(this));}
>
> // Called whenever an object is destroyed.
> myTestClass.prototype.clearEvents = function()
> {
>    var myDiv1 = $('exampleDiv1');
>    myDiv1.stopObserving('click');           // Is this line acceptable
> to stop ALL click events for myDiv1?
>
> }
>
> Many thanks,
> Lea Hayes
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to