[Proto-Scripty] Re: Question regarding Element.observe and Element.stopObserving
This works great, until a form or input element, is within the element hierarchy. It is mainly a problem with the HTML input tag, because most of the time (especially in ASP.NET) everything is contained within the form. html head titleTest Page/title script type=text/javascript src=prototype.js/script script type=text/javascript Object.extend(Element.Methods, { stopObservingNested: function(element) { element.stopObserving(); element.descendants().each(Element.stopObserving); } }); Element.addMethods(); window.onload = function() { $('testDiv').observe('click', function(event) { alert('clicked div'); }); $('testSpan').observe('click', function(event) { alert('clicked span'); }); $('testClear').observe('click', function(event) { var el = $('testDiv'); el.stopObservingNested(); }); } /script /head body div id=testDiv !-- Form causes eventName.include is not a function prototype.js Line: 3942 form span id=testSpan Hello World! /span /form nbsp;-nbsp;Div Part! /div input id=testClear type=button value=Clear Events / /body /html 2008/10/3 kangax [EMAIL PROTECTED]: On Oct 3, 7:31 am, Lea Hayes [EMAIL PROTECTED] wrote: Hi, Ah right, that's fair enough. When I wrote that post I didn't realize that you could simply pass a function reference into the each method. Personally I prefer to take advantage of the slightly higher level interfaces provided by Prototype to avoid possible difficulties in future releases. I did encounter one problem which was relatively simple to solve. If a form, or input element is nested within the specified element hierarchy, a JavaScript error is reported. By testing for the presence of 'stopObserving' method, it is possible to determine whether that method is appropriate on a per element basis: Object.extend(Element.Methods, { stopObservingNested: function(element) { element.stopObserving(); element.descendants().each(function(element) { if (element.stopObserving !== undefined) element.stopObserving(); }); } }); That's weird. `descendants` should return an array of extended elements and every extended element should have `stopObserving` (among other methods) Could you give more details on when this happens? -- 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: Question regarding Element.observe and Element.stopObserving
Still not like what it does to the Event.cache. If you plan an app that should work 8 hours a day, without browser refresh - hey, we are moving on to the browser or what ;) - I think that every bit should be considered, and in an interface with 3 or 4 active windows at time, each one with dozens of comps listening god knows what, and a create/ destroy cycle of about two or tree windows per minute... I dont know... One other thing that maybe fits beter in fresh new topic: element.visible() Its just not ok. When I want to know if that element is visible, I mean by the users point of view, so, if its display is not none but its div container is, well, thats pretty unvisible to me. So... isVisible: function(element) { var ok = $(element).visible(); if (!ok) return false; $(element).ancestors().each( function(obj){ if (!obj.visible()) throw $break; } ); return ok; } ...or please a better optimized way to do that ;) []'s Labs On Oct 4, 6:09 pm, kangax [EMAIL PROTECTED] wrote: On Oct 3, 7:26 pm, Lea Hayes [EMAIL PROTECTED] wrote: This works great, until a form or input element, is within the element hierarchy. It is mainly a problem with the HTML input tag, because most of the time (especially in ASP.NET) everything is contained within the form. html head titleTest Page/title script type=text/javascript src=prototype.js/script script type=text/javascript Object.extend(Element.Methods, { stopObservingNested: function(element) { element.stopObserving(); element.descendants().each(Element.stopObserving); } }); Element.addMethods(); window.onload = function() { $('testDiv').observe('click', function(event) { alert('clicked div'); }); $('testSpan').observe('click', function(event) { alert('clicked span'); }); $('testClear').observe('click', function(event) { var el = $('testDiv'); el.stopObservingNested(); }); } /script /head body div id=testDiv !-- Form causes eventName.include is not a function prototype.js Line: 3942 form span id=testSpan Hello World! /span /form nbsp;-nbsp;Div Part! /div input id=testClear type=button value=Clear Events / /body /html I'm an idiot : ) This error has nothing to do with the form, but is due to the way `stopObserving` works. We had this issue fixed in a trunk but then it was temporarily removed before 1.6.0.3 release. The problem is that `stopObserving` accepts optional 2nd and 3rd arguments and when passed as an iterator (to `each`) it gets called with `value` and `index` arguments that are being passed to an iterator. You can use `invoke` meanwhile (don't forget to extend an element first and then return it from the method): Element.addMethods({ stopObservingNested: function(element) { element = $(element); element.descendants().invoke('stopObserving'); return element.stopObserving(); } }); -- 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: Question regarding Element.observe and Element.stopObserving
Yes, that solves the problem, it now works in IE7/8+FF3. Sadly in Chrome it doesn't appear to work at all. Clicking the stop button does absolutely nothing, yet the method is being called because I tried sticking a test message box in there. The box appears, but the events are simply not stopped. I tried going to the Chrome console to find out if any errors were being reported, and it breaks even earlier saying that '.observe' is not a function. html head titleTest Page/title script type=text/javascript src=prototype.js/script script type=text/javascript Object.extend(Element.Methods, { stopObservingNested: function(element) { alert('about to stop events...'); element.descendants().invoke('stopObserving'); element.stopObserving(); alert('stopped events! - supposidly'); return element; } }); Element.addMethods(); window.onload = function() { $('testDiv').observe('click', function(event) { alert('clicked div'); }); $('testSpan').observe('click', function(event) { alert('clicked span'); }); $('testClear').observe('click', function(event) { var el = $('testDiv'); el.stopObservingNested(); }); } /script /head body div id=testDiv form span id=testSpan Hello World! /span /form nbsp;-nbsp;Div Part! /div input id=testClear type=button value=Clear Events / /body /html 2008/10/4 kangax [EMAIL PROTECTED]: On Oct 3, 7:26 pm, Lea Hayes [EMAIL PROTECTED] wrote: This works great, until a form or input element, is within the element hierarchy. It is mainly a problem with the HTML input tag, because most of the time (especially in ASP.NET) everything is contained within the form. html head titleTest Page/title script type=text/javascript src=prototype.js/script script type=text/javascript Object.extend(Element.Methods, { stopObservingNested: function(element) { element.stopObserving(); element.descendants().each(Element.stopObserving); } }); Element.addMethods(); window.onload = function() { $('testDiv').observe('click', function(event) { alert('clicked div'); }); $('testSpan').observe('click', function(event) { alert('clicked span'); }); $('testClear').observe('click', function(event) { var el = $('testDiv'); el.stopObservingNested(); }); } /script /head body div id=testDiv !-- Form causes eventName.include is not a function prototype.js Line: 3942 form span id=testSpan Hello World! /span /form nbsp;-nbsp;Div Part! /div input id=testClear type=button value=Clear Events / /body /html I'm an idiot : ) This error has nothing to do with the form, but is due to the way `stopObserving` works. We had this issue fixed in a trunk but then it was temporarily removed before 1.6.0.3 release. The problem is that `stopObserving` accepts optional 2nd and 3rd arguments and when passed as an iterator (to `each`) it gets called with `value` and `index` arguments that are being passed to an iterator. You can use `invoke` meanwhile (don't forget to extend an element first and then return it from the method): Element.addMethods({ stopObservingNested: function(element) { element = $(element); element.descendants().invoke('stopObserving'); return element.stopObserving(); } }); -- 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: Question regarding Element.observe and Element.stopObserving
On Oct 3, 7:26 pm, Lea Hayes [EMAIL PROTECTED] wrote: This works great, until a form or input element, is within the element hierarchy. It is mainly a problem with the HTML input tag, because most of the time (especially in ASP.NET) everything is contained within the form. html head titleTest Page/title script type=text/javascript src=prototype.js/script script type=text/javascript Object.extend(Element.Methods, { stopObservingNested: function(element) { element.stopObserving(); element.descendants().each(Element.stopObserving); } }); Element.addMethods(); window.onload = function() { $('testDiv').observe('click', function(event) { alert('clicked div'); }); $('testSpan').observe('click', function(event) { alert('clicked span'); }); $('testClear').observe('click', function(event) { var el = $('testDiv'); el.stopObservingNested(); }); } /script /head body div id=testDiv !-- Form causes eventName.include is not a function prototype.js Line: 3942 form span id=testSpan Hello World! /span /form nbsp;-nbsp;Div Part! /div input id=testClear type=button value=Clear Events / /body /html I'm an idiot : ) This error has nothing to do with the form, but is due to the way `stopObserving` works. We had this issue fixed in a trunk but then it was temporarily removed before 1.6.0.3 release. The problem is that `stopObserving` accepts optional 2nd and 3rd arguments and when passed as an iterator (to `each`) it gets called with `value` and `index` arguments that are being passed to an iterator. You can use `invoke` meanwhile (don't forget to extend an element first and then return it from the method): Element.addMethods({ stopObservingNested: function(element) { element = $(element); element.descendants().invoke('stopObserving'); return element.stopObserving(); } }); -- 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: Question regarding Element.observe and Element.stopObserving
Hi, Ah right, that's fair enough. When I wrote that post I didn't realize that you could simply pass a function reference into the each method. Personally I prefer to take advantage of the slightly higher level interfaces provided by Prototype to avoid possible difficulties in future releases. I did encounter one problem which was relatively simple to solve. If a form, or input element is nested within the specified element hierarchy, a JavaScript error is reported. By testing for the presence of 'stopObserving' method, it is possible to determine whether that method is appropriate on a per element basis: Object.extend(Element.Methods, { stopObservingNested: function(element) { element.stopObserving(); element.descendants().each(function(element) { if (element.stopObserving !== undefined) element.stopObserving(); }); } }); 2008/10/3 kangax [EMAIL PROTECTED]: On Oct 2, 6:15 pm, Lea Hayes [EMAIL PROTECTED] wrote: Or as puckpuck suggested with the 'descendants' method instead of the CSS selector for greatly improved performance. `Element.descendants` uses `Element.select` internally. That's why I used `select` directly (to avoid an extra function call). `_each` is there to avoid try/catch which is not really needed as far as I can see. Also, passing `Event.stopObserving` as an iterator avoids an extra function : ) Object.extend(Element.prototype, { stopObservingNested: function() { this.stopObserving(); this.descendants().each(function(el) { el.stopObserving(); }); } }); I have tested the above, and it appears to work fine. Best regards, Lea Hayes -- 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: Question regarding Element.observe and Element.stopObserving
Yeah. I know. I did that: Element.addMethods({ clearEvents: function(element) { element.descendants().each( function(obj){ if (obj._prototypeEventID) { obj.stopObserving(); } } ); element.stopObserving(); return element; } }); I just dont like to extend core features as it makes hard to upgrade to newer verions later. Thanks for your answer. ;) []'s Labs 2008/10/2 puckpuck [EMAIL PROTECTED] This exact question was asked today at TAE. At this time, no. stopObserving will not go through the children of the container and remove events. In the future it is certainly possible. Mind you it wouldn't be very difficult to write your own method to recurse through all the children of a given element, and call stopObserving on those children. var elem = $(myElement); elem.stopObserving() elem.select(*).invoke(stopObserving); On Oct 1, 11:02 am, labs2.0 [EMAIL PROTECTED] wrote: Hi. Please, would you be kind to clearify this to me: if I call Event.stopObserving(myWindow), beeing 'myWindow' a div (ajax generated window wich can came and go as the user will), who doesnt have observers, but its a container (and parent) for many other elements (components) that may does, may doesn't have observers, will this call work recursivelly? If dont, why??? Assuming it doesnt, and that prototype beautifully make things in a clean and natural way, should'nt we espect some behaviour like that? I mean, in a large framework, where I create a window with many comps, one could say that its my job to create a event garbage collector (which I did hacking prototype 1.5.0) to clean up things when, say, a window pops out, but then again, if I already have a nice way to setup events, its ask too much to have a nice one to get rid off of all of them too? :) In prototype 1.5.0 I've hacked a Event.observeFor(container, element, event) and a Event.unloadContainer(container); for memory sake. Am I missing something new (and cool) about Events here? Thank you and let me be +1 to say that prototype ROCKS!! []'s Labs On 10 set, 09:38, T.J. Crowder [EMAIL PROTECTED] wrote: Hi folks, try a look at the API documentation: http://www.prototypejs.org/api/event/stopObserving (you exactly do what is wrong !!) Actually, David, what she's doing is just fine. She's using a new(ish) feature of stopObserving which appears to be missing from the docs. If you don't include a handler in the stopObserving call, ALL events hooked up by observe() for the giveneventname on the given element will be removed. This is quite handy. Even better, if you leave off theeventname as well, stopObserving() will unhook all of the handlers for that element [that were set up by observe()] entirely. So this would be wrong: Event.observe(myelement, 'click', this.clickHandler.bindAsEventListener(this)); ... Event.stopObserving(myelement, 'click', this.clickHandler.bindAsEventListener(this)); because the function arguments don't match. But this is fine: Event.observe(myelement, 'click', this.clickHandler.bindAsEventListener(this)); ... Event.stopObserving(myelement, 'click'); It removes *all* click handlers hooked using observe() from the element. And this is fine: Event.observe(myelement, 'click', this.clickHandler.bindAsEventListener(this)); ... Event.stopObserving(myelement); It removes *all* handlers for all events hooked using observe() from the element. Great for when you're about to remove the element. I'll see if there's a doc ticket in Lighthouse for this and add one if there isn't. -- T.J. Crowder tj / crowder software / com On Sep 10, 12:14 pm, david [EMAIL PROTECTED] wrote: 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 stopeventobserve: 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 alleventfrom 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
[Proto-Scripty] Re: Question regarding Element.observe and Element.stopObserving
When I made that post, I was very groggy, and realized I used a CSS selector *, which well... is horrid slow, especially on IE. using elem.descendants() instead would of made far more sense. Also I would stay away from checking on the existing of _prototypeEventID on the element. This is an internal prototype property, which can change at any time. Relying on such a property can be dangerous when you attempt to do an upgrade, even a small, bug fix one. The stopObserving method, will check the internal prototype registry for events, which is very fast, and recommended. On Oct 2, 9:03 am, Lea Hayes [EMAIL PROTECTED] wrote: Hi puckpuck!, That's a really handy little snippet, so much simpler than manually enumerating nested HTML elements and stopping them individually (which I have previously done). If this functionality were to be bundled within the Prototype framework I personally think it would be better to offer an additional method (i.e. stopObservingNested or the like). Otherwise, the stopObserving method could cause undesirable effects, like if nested events are still wanted. Thanks! Lea Hayes 2008/10/2 puckpuck [EMAIL PROTECTED]: This exact question was asked today at TAE. At this time, no. stopObserving will not go through the children of the container and remove events. In the future it is certainly possible. Mind you it wouldn't be very difficult to write your own method to recurse through all the children of a given element, and call stopObserving on those children. var elem = $(myElement); elem.stopObserving() elem.select(*).invoke(stopObserving); On Oct 1, 11:02 am, labs2.0 [EMAIL PROTECTED] wrote: Hi. Please, would you be kind to clearify this to me: if I call Event.stopObserving(myWindow), beeing 'myWindow' a div (ajax generated window wich can came and go as the user will), who doesnt have observers, but its a container (and parent) for many other elements (components) that may does, may doesn't have observers, will this call work recursivelly? If dont, why??? Assuming it doesnt, and that prototype beautifully make things in a clean and natural way, should'nt we espect some behaviour like that? I mean, in a large framework, where I create a window with many comps, one could say that its my job to create a event garbage collector (which I did hacking prototype 1.5.0) to clean up things when, say, a window pops out, but then again, if I already have a nice way to setup events, its ask too much to have a nice one to get rid off of all of them too? :) In prototype 1.5.0 I've hacked a Event.observeFor(container, element, event) and a Event.unloadContainer(container); for memory sake. Am I missing something new (and cool) about Events here? Thank you and let me be +1 to say that prototype ROCKS!! []'s Labs On 10 set, 09:38, T.J. Crowder [EMAIL PROTECTED] wrote: Hi folks, try a look at the API documentation:http://www.prototypejs.org/api/event/stopObserving (you exactly do what is wrong !!) Actually, David, what she's doing is just fine. She's using a new(ish) feature of stopObserving which appears to be missing from the docs. If you don't include a handler in the stopObserving call, ALL events hooked up by observe() for the giveneventname on the given element will be removed. This is quite handy. Even better, if you leave off theeventname as well, stopObserving() will unhook all of the handlers for that element [that were set up by observe()] entirely. So this would be wrong: Event.observe(myelement, 'click', this.clickHandler.bindAsEventListener(this)); ... Event.stopObserving(myelement, 'click', this.clickHandler.bindAsEventListener(this)); because the function arguments don't match. But this is fine: Event.observe(myelement, 'click', this.clickHandler.bindAsEventListener(this)); ... Event.stopObserving(myelement, 'click'); It removes *all* click handlers hooked using observe() from the element. And this is fine: Event.observe(myelement, 'click', this.clickHandler.bindAsEventListener(this)); ... Event.stopObserving(myelement); It removes *all* handlers for all events hooked using observe() from the element. Great for when you're about to remove the element. I'll see if there's a doc ticket in Lighthouse for this and add one if there isn't. -- T.J. Crowder tj / crowder software / com On Sep 10, 12:14 pm, david [EMAIL PROTECTED] wrote: 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);
[Proto-Scripty] Re: Question regarding Element.observe and Element.stopObserving
Yeah, but if you firebug the Event object after recursive unregister, you will see that every element that doesnt had a _prototypeEventID will create an entry in Event.cache. This is because the way the eventId is generated and THERE I'll not mess with :) Those entry are empty, I know, but ohhh... its damn ugly. ;) P.s. agreed with the 'stopObservingNested' thing. []'s Labs 2008/10/2 puckpuck [EMAIL PROTECTED] When I made that post, I was very groggy, and realized I used a CSS selector *, which well... is horrid slow, especially on IE. using elem.descendants() instead would of made far more sense. Also I would stay away from checking on the existing of _prototypeEventID on the element. This is an internal prototype property, which can change at any time. Relying on such a property can be dangerous when you attempt to do an upgrade, even a small, bug fix one. The stopObserving method, will check the internal prototype registry for events, which is very fast, and recommended. On Oct 2, 9:03 am, Lea Hayes [EMAIL PROTECTED] wrote: Hi puckpuck!, That's a really handy little snippet, so much simpler than manually enumerating nested HTML elements and stopping them individually (which I have previously done). If this functionality were to be bundled within the Prototype framework I personally think it would be better to offer an additional method (i.e. stopObservingNested or the like). Otherwise, the stopObserving method could cause undesirable effects, like if nested events are still wanted. Thanks! Lea Hayes 2008/10/2 puckpuck [EMAIL PROTECTED]: This exact question was asked today at TAE. At this time, no. stopObserving will not go through the children of the container and remove events. In the future it is certainly possible. Mind you it wouldn't be very difficult to write your own method to recurse through all the children of a given element, and call stopObserving on those children. var elem = $(myElement); elem.stopObserving() elem.select(*).invoke(stopObserving); On Oct 1, 11:02 am, labs2.0 [EMAIL PROTECTED] wrote: Hi. Please, would you be kind to clearify this to me: if I call Event.stopObserving(myWindow), beeing 'myWindow' a div (ajax generated window wich can came and go as the user will), who doesnt have observers, but its a container (and parent) for many other elements (components) that may does, may doesn't have observers, will this call work recursivelly? If dont, why??? Assuming it doesnt, and that prototype beautifully make things in a clean and natural way, should'nt we espect some behaviour like that? I mean, in a large framework, where I create a window with many comps, one could say that its my job to create a event garbage collector (which I did hacking prototype 1.5.0) to clean up things when, say, a window pops out, but then again, if I already have a nice way to setup events, its ask too much to have a nice one to get rid off of all of them too? :) In prototype 1.5.0 I've hacked a Event.observeFor(container, element, event) and a Event.unloadContainer(container); for memory sake. Am I missing something new (and cool) about Events here? Thank you and let me be +1 to say that prototype ROCKS!! []'s Labs On 10 set, 09:38, T.J. Crowder [EMAIL PROTECTED] wrote: Hi folks, try a look at the API documentation: http://www.prototypejs.org/api/event/stopObserving (you exactly do what is wrong !!) Actually, David, what she's doing is just fine. She's using a new(ish) feature of stopObserving which appears to be missing from the docs. If you don't include a handler in the stopObserving call, ALL events hooked up by observe() for the giveneventname on the given element will be removed. This is quite handy. Even better, if you leave off theeventname as well, stopObserving() will unhook all of the handlers for that element [that were set up by observe()] entirely. So this would be wrong: Event.observe(myelement, 'click', this.clickHandler.bindAsEventListener(this)); ... Event.stopObserving(myelement, 'click', this.clickHandler.bindAsEventListener(this)); because the function arguments don't match. But this is fine: Event.observe(myelement, 'click', this.clickHandler.bindAsEventListener(this)); ... Event.stopObserving(myelement, 'click'); It removes *all* click handlers hooked using observe() from the element. And this is fine: Event.observe(myelement, 'click', this.clickHandler.bindAsEventListener(this)); ... Event.stopObserving(myelement); It removes *all* handlers for all events hooked using observe() from the element. Great for when you're about to remove the element. I'll see if there's a doc ticket in Lighthouse for this and add
[Proto-Scripty] Re: Question regarding Element.observe and Element.stopObserving
Or as puckpuck suggested with the 'descendants' method instead of the CSS selector for greatly improved performance. Object.extend(Element.prototype, { stopObservingNested: function() { this.stopObserving(); this.descendants().each(function(el) { el.stopObserving(); }); } }); I have tested the above, and it appears to work fine. Best regards, Lea Hayes 2008/10/2 kangax [EMAIL PROTECTED]: On Oct 2, 9:57 am, labs [EMAIL PROTECTED] wrote: Yeah, but if you firebug the Event object after recursive unregister, you will see that every element that doesnt had a _prototypeEventID will create an entry in Event.cache. This is because the way the eventId is generated and THERE I'll not mess with :) Those entry are empty, I know, but ohhh... its damn ugly. ;) P.s. agreed with the 'stopObservingNested' thing. I believe something like this is enought: Element.Methods.purge = function(element) { element = $(element); [element].concat(element.select('*')))._each(Event.stopObserving); return element; } []'s Labs -- 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: Question regarding Element.observe and Element.stopObserving
On Oct 2, 6:15 pm, Lea Hayes [EMAIL PROTECTED] wrote: Or as puckpuck suggested with the 'descendants' method instead of the CSS selector for greatly improved performance. `Element.descendants` uses `Element.select` internally. That's why I used `select` directly (to avoid an extra function call). `_each` is there to avoid try/catch which is not really needed as far as I can see. Also, passing `Event.stopObserving` as an iterator avoids an extra function : ) Object.extend(Element.prototype, { stopObservingNested: function() { this.stopObserving(); this.descendants().each(function(el) { el.stopObserving(); }); } }); I have tested the above, and it appears to work fine. Best regards, Lea Hayes -- 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 -~--~~~~--~~--~--~---