Hi. I''ve seen 2 ways of doing this ... 1 - The AJAX response is HTML and that is used to update the select tag. 2 - The AJAX response is iterated to add items to the select tag. I''m using X-JSON header to return an array of name/value pairs. Is there a built in function to populate a select tag? Or do I need to use one of the 2 methods described above? Thanks, Richard Quadling. -- ----- 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 -~----------~----~----~----~------~----~------~--~---
I would use option #2. (Yes, there is no native function to populate <select> from an array.) On Jul 20, 4:22 am, "Richard Quadling" <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi. > > I''ve seen 2 ways of doing this ... > > 1 - The AJAX response is HTML and that is used to update the select tag. > 2 - The AJAX response is iterated to add items to the select tag. > > I''m using X-JSON header to return an array of name/value pairs. Is > there a built in function to populate a select tag? Or do I need to > use one of the 2 methods described above? > > Thanks, > > Richard Quadling. > > -- > ----- > 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 -~----------~----~----~----~------~----~------~--~---
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> <font face="Helvetica, Arial, sans-serif">I''m working on a web application that controls media players over the internet. The app needs to send and receive AJAX XHR requests/responses formatted as JSON objects. I''m doing this using the Prototype library.<br> <br> These are not directly related to the standard CRUD screens, but will be used to issue commands to multiple clients, from an AJAX JSON request that contains a command and an array of client names.<br> <br> The server will also need to generate AJAX JSON responses, containing a client name along with an array of fields whose data has changed. These are to be parsed on the client and will update cells in a table indicating the current state of individual clients.<br> <br> Since I haven''t done this before, I''m trying to understand if there is a place in the current rails code that I should hook into, or if I need a new controller to handle the AJAX requests/responses. I''m using Ruby to hande the server code and I''m looking for an example that receives AJAX XHR requests and handles them using Ruby.<br> <br> Any suggestions or code samples of others who have tackled this issue would be greatly appreciated. To get a better understanding of what the App is up to, you can view it at: <a class="moz-txt-link-freetext" href="http://24.23.248.71">http://24.23.248.71 </a>The page that this problem refers to is here: <br> <a class="moz-txt-link-freetext" href="http://24.23.248.71/wm/public/index.html">http://24.23.248.71/wm/public/index.html</a> If you''ve got Firebug running, you''ll see the command generated in the Console window, provided at least one client is checked.<br> <br> Any pointers, code examples, or explanations as to how this might or should be done are sincerely appreciated.<br> <br> Thanks,</font><br> -- Steve<br> <br> --~--~---------~--~----~------------~-------~--~----~<br> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. <br> To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en <br> -~----------~----~----~----~------~----~------~--~---<br> </body> </html> <br>
Hi, lucky you I recently finished up such a thing ;o) I packaged it and wrote an example for you. have fun Bastian On 7/20/07, Diodeus <diodeus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > I would use option #2. (Yes, there is no native function to populate > <select> from an array.) > > On Jul 20, 4:22 am, "Richard Quadling" <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > > Hi. > > > > I''ve seen 2 ways of doing this ... > > > > 1 - The AJAX response is HTML and that is used to update the select tag. > > 2 - The AJAX response is iterated to add items to the select tag. > > > > I''m using X-JSON header to return an array of name/value pairs. Is > > there a built in function to populate a select tag? Or do I need to > > use one of the 2 methods described above? > > > > Thanks, > > > > Richard Quadling. > > > > -- > > ----- > > Richard Quadling > > Zend Certified Engineer : > http://zend.com/zce.php?c=ZEND002498&r=213474731 > > "Standing on the shoulders of some very clever giants!" > > > > >-- -- spread the word ... see www.browsehappy.com ;o) Calvin: Weekends don''t count unless you spend them doing something completely pointless. Join the Greater IBM Connection ( http://www.xing.com/premiumgroup-6291.d26b7d) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I have used option #2 of iterating over a collection. What is cool about the select element is that both IE and FF support adding option elements directly to the options array. Its just as you had used appendChild but a lot faster. A very handy tip when working with large data sets. On Jul 20, 1:51 pm, "Bastian Feder" <bastian.fe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > lucky you I recently finished up such a thing ;o) > > I packaged it and wrote an example for you. > > have fun > Bastian > > On 7/20/07, Diodeus <diod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > I would use option #2. (Yes, there is no native function to populate > > <select> from an array.) > > > On Jul 20, 4:22 am, "Richard Quadling" <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > > wrote: > > > Hi. > > > > I''ve seen 2 ways of doing this ... > > > > 1 - The AJAX response is HTML and that is used to update the select tag. > > > 2 - The AJAX response is iterated to add items to the select tag. > > > > I''m using X-JSON header to return an array of name/value pairs. Is > > > there a built in function to populate a select tag? Or do I need to > > > use one of the 2 methods described above? > > > > Thanks, > > > > Richard Quadling. > > > > -- > > > ----- > > > Richard Quadling > > > Zend Certified Engineer : > >http://zend.com/zce.php?c=ZEND002498&r=213474731 > > > "Standing on the shoulders of some very clever giants!" > > -- > -- > spread the word ... seewww.browsehappy.com;o) > > Calvin: Weekends don''t count unless you spend them doing something > completely pointless. > > Join the Greater IBM Connection (http://www.xing.com/premiumgroup-6291.d26b7d) > > lib.cascadingSelects.js.zip > 14KDownload--~--~---------~--~----~------------~-------~--~----~ 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 20/07/07, Bastian Feder <bastian.feder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > lucky you I recently finished up such a thing ;o) > > I packaged it and wrote an example for you. > > have fun > Bastian > > On 7/20/07, Diodeus <diodeus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I would use option #2. (Yes, there is no native function to populate > > <select> from an array.) > > > > On Jul 20, 4:22 am, "Richard Quadling" <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org > > > wrote: > > > Hi. > > > > > > I''ve seen 2 ways of doing this ... > > > > > > 1 - The AJAX response is HTML and that is used to update the select tag. > > > 2 - The AJAX response is iterated to add items to the select tag. > > > > > > I''m using X-JSON header to return an array of name/value pairs. Is > > > there a built in function to populate a select tag? Or do I need to > > > use one of the 2 methods described above? > > > > > > Thanks, > > > > > > Richard Quadling.WOW. Excellent. I''m extremely grateful for your efforts. A question. In the onSuccess handler (cSelection.onSuccessRequest), you have 4 parameters. Using IE 7 and FF 2.0.0.5, the 4th parameter is always returned as null and as such $(jso) causes an exception (nicely caught BTW). Can you give a quick pointer on this? -- ----- 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 -~----------~----~----~----~------~----~------~--~---
Hey Richard, ups .. sry me I forgot that I altered the prototype.js to my needs .. pls take the attached one. The main difference between the original prototype and tmine is one of my favorit features in Rio .. the >do not forget yourself< feature ;o) Means normally prototype does not keep any information about the object the AJAX Request has been fired from, but in many cases this is essential (e.gto call a method of the object or accessing properties). The >jso< item in the options parameter passes the complete object (this) to the AJAX request and is handled inside prototype. As consequence the jso- option will be passed to every >on[..]< method you define. Additionally I added more descriptive excetion messages to the exceptions thrown be prototype. About your question: Where did you find the 4th parameter?? I sent your version: lib.cascadingSelects.js,v 1.5 2007/05/04 09:17:20 ? Did I ?? hf Bastian On 7/23/07, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > > On 20/07/07, Bastian Feder <bastian.feder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi, > > lucky you I recently finished up such a thing ;o) > > > > I packaged it and wrote an example for you. > > > > have fun > > Bastian > > > > On 7/20/07, Diodeus <diodeus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > I would use option #2. (Yes, there is no native function to populate > > > <select> from an array.) > > > > > > On Jul 20, 4:22 am, "Richard Quadling" <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org > > > > wrote: > > > > Hi. > > > > > > > > I''ve seen 2 ways of doing this ... > > > > > > > > 1 - The AJAX response is HTML and that is used to update the select > tag. > > > > 2 - The AJAX response is iterated to add items to the select tag. > > > > > > > > I''m using X-JSON header to return an array of name/value pairs. Is > > > > there a built in function to populate a select tag? Or do I need to > > > > use one of the 2 methods described above? > > > > > > > > Thanks, > > > > > > > > Richard Quadling. > > WOW. Excellent. I''m extremely grateful for your efforts. > > A question. > > In the onSuccess handler (cSelection.onSuccessRequest), you have 4 > parameters. > > Using IE 7 and FF 2.0.0.5, the 4th parameter is always returned as > null and as such $(jso) causes an exception (nicely caught BTW). > > Can you give a quick pointer on this? > > -- > ----- > Richard Quadling > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!" > > > >-- -- spread the word ... see www.browsehappy.com ;o) Calvin: Weekends don''t count unless you spend them doing something completely pointless. Join the Greater IBM Connection ( http://www.xing.com/premiumgroup-6291.d26b7d) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---