I have a function that needs to be attached to a bunch of text fields when the page loads. I would like to use the Prototype methods that are added to DOM elements by using the $() function, but I in the function it refers to things with "this". For example, this.style.borderColor. Is there a way to extend elements from the kind of scope I am looking at? For example, is there a way to do $(this)? Thanks for any help. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 04/11/2007, bgetting <brian-tB76j2tlwt5qMpX8nAm8aq7InAxgj2Y1@public.gmane.org> wrote:> > I have a function that needs to be attached to a bunch of text fields > when the page loads. I would like to use the Prototype methods that > are added to DOM elements by using the $() function, but I in the > function it refers to things with "this". For example, > this.style.borderColor. > > Is there a way to extend elements from the kind of scope I am looking > at? For example, is there a way to do $(this)? > > Thanks for any help. > > > > >Is it ALL text fields? If so, something like this ... Element.addMethods ( ''SELECT'', { selectValue : function(element, s_Value) { element = $(element); element.selectedIndex = $A(element.options).pluck(''value'').indexOf(s_Value); return element; } } ); I''m adding a new method to my SELECT tags. $(''selectCity'').selectValue(''Plymouth''); Will make the option whose value is Plymouth the select option. No "this" as element is the correct thing to talk to. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks, Richard. I''m going to look into that today, but after reviewing the API documentation I think you are right on with that solution. Thanks for your help. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Apparently Analagous Threads
- insert HTML <select> value into a textarea - Works in IE6, not in FireFox or Opera
- Tripp Lite SMART3000RM2U (protocol 3003) running time and charge?
- Tripp Lite SMART3000RM2U (protocol 3003) running time and charge?
- Tripp Lite SMART3000RM2U (protocol 3003) running time and charge?
- Tripp Lite SMART3000RM2U (protocol 3003) running time and charge?