[Proto-Scripty] Re: How can I stop the observers?

2008-09-20 Thread kangax

On Sep 20, 11:32 am, bluezehn [EMAIL PROTECTED] wrote:
 You haven't read the API well enough then. Separate files essentially
 mean very, very little.

 You need to keep a reference to the function that you set on the
 observer. What's important to realise here is that in javascript you
 have instances of functions, in exactly the same way as you might have
 an instance of a class in OOP. So you have something like:

 function foo()
 {...}

 var fooInst = foo;
 element#observe('event', fooInst);
 element#stopObserving('event', fooInst);

 as long as the fooInst variable is global, ie, referencable by any
 javascript anywhere, it doesn't matter where you stop observing it
 from.

Saying that a reference has to be global is a little confusing.
Reference is a reference. As long as it points to the same function
that was used in `Event.observe`, everything should work. It doesn't
really matter how you store that reference and where you store it : )


 Also, I believe in the latest version of prototype that:
 element#stopObserving()
 with no parameters, stops all observers on that element.

Yep.

--
kangax
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: How can I stop the observers?

2008-09-19 Thread bluezehn

look at api, it's always a good place to look for when you want to...
um... refer to the application programming intercace
http://www.prototypejs.org/api/event/stopObserving

On Sep 19, 9:30 pm, Cristisor [EMAIL PROTECTED] wrote:
 Hi. I have a small problem: I have an auto suggest that makes a
 request to the server every time I type a new character. But the url
 for the request depends on a 'region_value' that can be changed at any
 time. So if I have my auto suggest is set for a default region and I
 need to change the region I have to declare another auto suggest, but
 this means I will have 2 auto suggests and it looks bad. So I need to
 destroy the first auto suggest and I think I can do this by destroying
 all the observers on my object, because they trigger the auto suggest.
 Any idea how I can do this? Thanks!
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---