Hi i am using prototype.js in my rails app via observe_field and RJS. For the most part it works except when I attempted to update some HTML elements at the end. On the controller side, I am using the following bit of code render :update do |page| page.replace_html ''field2'', h(field2) page.replace_html ''field3'', h(field3) page.replace_html ''field4'', h(field4) end In IE7, I got a Javascript error dialog box "rjs error: [object Error]". I also got a follow-on error dialog box showing all 3 elements "Element.update("field2", "value..."); Element.update("field3", "value..."); Element.update("field4", "value...");" Alas but field4 never got updated, and field3 has both field3 and field4 values. Can anyone help? Thanks in advance 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 -~----------~----~----~----~------~----~------~--~---
Digging in further, this appears to be a bug with prototype.js for html input element type. If I switch field4 to textarea type, it works fine, anyone came across this problem? On Jul 8, 9:14 pm, bngu <bob_...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> Hi i am using prototype.js in my rails app via observe_field and RJS. > For the most part it works except when I attempted to update some HTML > elements at the end. On the controller side, I am using the following > bit of code > > render :update do |page| > page.replace_html ''field2'', h(field2) > page.replace_html ''field3'', h(field3) > page.replace_html ''field4'', h(field4) > end > > In IE7, I got a Javascript error dialog box "rjs error: [object > Error]". I also got a follow-on error dialog box showing all 3 > elements "Element.update("field2", "value..."); > Element.update("field3", "value..."); Element.update("field4", > "value...");" Alas but field4 never got updated, and field3 has both > field3 and field4 values. Can anyone help? Thanks in advance 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 -~----------~----~----~----~------~----~------~--~---
bngu wrote:> Digging in further, this appears to be a bug with prototype.js for > html input element type. If I switch field4 to textarea type, it works > fine, anyone came across this problem? >Element.update() uses innerHTML. To change the value of an input field, use $(''field'').value = ''new value''; -- Ken Snyder --~--~---------~--~----~------------~-------~--~----~ 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 Ken. Is there an easy way to do that in rails? I assume that the syntax is page.replace_html but perhaps not On Jul 9, 10:16 am, Ken Snyder <kendsny...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> bngu wrote: > > Digging in further, this appears to be a bug with prototype.js for > > html input element type. If I switch field4 to textarea type, it works > > fine, anyone came across this problem? > > Element.update() uses innerHTML. To change the value of an input field, > use $(''field'').value = ''new value''; > > -- Ken Snyder--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Sounds like this could be an enhancement request: have Ajax.Update detect if the passed element is an input, and if so, update the value rather than the innerHTML. Does a core dev want to sound off on whether a patch to that effect would be implemented? TAG On Jul 9, 2007, at 12:39 PM, bngu wrote:> > Thanks Ken. Is there an easy way to do that in rails? I assume that > the syntax is page.replace_html but perhaps not > > On Jul 9, 10:16 am, Ken Snyder <kendsny...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> bngu wrote: >>> Digging in further, this appears to be a bug with prototype.js for >>> html input element type. If I switch field4 to textarea type, it >>> works >>> fine, anyone came across this problem? >> >> Element.update() uses innerHTML. To change the value of an input >> field, >> use $(''field'').value = ''new value''; >> >> -- Ken Snyder > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
After some more digging, I found a way the syntax to changing the value of an input element in Rails RJS. Instead of using page.replace_html, I have to do it like this page[:field_id].value = .... This is cool stuff, but it does mean that you need to understand prototype.js functions which is technically part of Rails. Thanks everyone. On Jul 9, 11:39 am, bngu <bob_...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> Thanks Ken. Is there an easy way to do that in rails? I assume that > the syntax is page.replace_html but perhaps not > > On Jul 9, 10:16 am, Ken Snyder <kendsny...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > bngu wrote: > > > Digging in further, this appears to be a bug with prototype.js for > > > html input element type. If I switch field4 to textarea type, it works > > > fine, anyone came across this problem? > > > Element.update() uses innerHTML. To change the value of an input field, > > use $(''field'').value = ''new value''; > > > -- Ken Snyder--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---