When I add my own extensions to DOM elements, is there a way to only add my extensions to the specific types of DOM elements (e.g. SELECT) to which my extensions apply or are intended to operate? Based on the Prototype API documentation (http://prototypejs.org/learn/ extensions), it appears that anytime I extend an element, all the extensions (Prototype''s and my own) are copied to that element regardless of the element''s type. For example, I have a collection of extensions for operating on just SELECT elements. However, I don''t want to copy these extensions to the non-SELECT elements that I also extend using the $ utility method, Element.extend, etc. For obvious reasons, if I extend a DIV element, I don''t want all my SELECT extensions to be copied to it. Am I correct in assuming that Prototype copies all my extensions to an extended element regardless of its type? If so, is it possible to do otherwise? Though it does not appear to me that it does so, does Prototype already handle this? If not, does Prototype have the capacity to handle it? If so, how? Thanks in advance for any help group user are able to provide. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Nicolás Sanguinetti
2008-Feb-07 19:58 UTC
Re: Adding my own extensions with Elements.addMethods()
http://prototypejs.org/api/element/addMethods :) Element.addMethods("select", { ... methods ... }); On Feb 7, 2008 5:37 PM, broberts <broberts80-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > When I add my own extensions to DOM elements, is there a way to only > add my extensions to the specific types of DOM elements (e.g. SELECT) > to which my extensions apply or are intended to operate? > > Based on the Prototype API documentation (http://prototypejs.org/learn/ > extensions), it appears that anytime I extend an element, all the > extensions (Prototype''s and my own) are copied to that element > regardless of the element''s type. > > For example, I have a collection of extensions for operating on just > SELECT elements. However, I don''t want to copy these extensions to > the non-SELECT elements that I also extend using the $ utility method, > Element.extend, etc. > > For obvious reasons, if I extend a DIV element, I don''t want all my > SELECT extensions to be copied to it. Am I correct in assuming that > Prototype copies all my extensions to an extended element regardless > of its type? > > If so, is it possible to do otherwise? Though it does not appear to > me that it does so, does Prototype already handle this? If not, does > Prototype have the capacity to handle it? If so, how? > > Thanks in advance for any help group user are able to provide. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Martin Ström
2008-Feb-07 20:00 UTC
Re: Adding my own extensions with Elements.addMethods()
You''re looking for <http://prototypejs.org/api/element/addmethods> and that you can pass a tagname along with the new methods. Martin On 07/02/2008, broberts <broberts80-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > When I add my own extensions to DOM elements, is there a way to only > add my extensions to the specific types of DOM elements (e.g. SELECT) > to which my extensions apply or are intended to operate? > > Based on the Prototype API documentation (http://prototypejs.org/learn/ > extensions), it appears that anytime I extend an element, all the > extensions (Prototype''s and my own) are copied to that element > regardless of the element''s type. > > For example, I have a collection of extensions for operating on just > SELECT elements. However, I don''t want to copy these extensions to > the non-SELECT elements that I also extend using the $ utility method, > Element.extend, etc. > > For obvious reasons, if I extend a DIV element, I don''t want all my > SELECT extensions to be copied to it. Am I correct in assuming that > Prototype copies all my extensions to an extended element regardless > of its type? > > If so, is it possible to do otherwise? Though it does not appear to > me that it does so, does Prototype already handle this? If not, does > Prototype have the capacity to handle it? If so, how? > > Thanks in advance for any help group user are able to provide. > > >-- burnfield.com/martin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Excellent. Thanks guys! I knew I was not the first person to have this thought. On Feb 7, 2:00 pm, "Martin Ström" <martinstromli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You''re looking for <http://prototypejs.org/api/element/addmethods> and > that you can pass a tagname along with the new methods. > > Martin > > On 07/02/2008, broberts <brobert...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > When I add my own extensions to DOM elements, is there a way to only > > add my extensions to the specific types of DOM elements (e.g. SELECT) > > to which my extensions apply or are intended to operate? > > > Based on the Prototype API documentation (http://prototypejs.org/learn/ > > extensions), it appears that anytime I extend an element, all the > > extensions (Prototype''s and my own) are copied to that element > > regardless of the element''s type. > > > For example, I have a collection of extensions for operating on just > > SELECT elements. However, I don''t want to copy these extensions to > > the non-SELECT elements that I also extend using the $ utility method, > > Element.extend, etc. > > > For obvious reasons, if I extend a DIV element, I don''t want all my > > SELECT extensions to be copied to it. Am I correct in assuming that > > Prototype copies all my extensions to an extended element regardless > > of its type? > > > If so, is it possible to do otherwise? Though it does not appear to > > me that it does so, does Prototype already handle this? If not, does > > Prototype have the capacity to handle it? If so, how? > > > Thanks in advance for any help group user are able to provide. > > -- > burnfield.com/martin--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---