iKs
2008-Dec-21 20:36 UTC
Form issues : partials + AJAX vs simple JS / separate views + form_fors vs one view and fields_fors
Hi all! I am coding an application that keeps track of request to create college courses. An identified user (logically a faculty member) completes a form indicating the name of the course, the professor in charge, the course''s code, the date and place, the possible coprofessors and TAs and the type of website he or she wants to use as a teaching help (WebCT, Sakai, etc.). I have two problems about what I''m doing. First of all, we can have from 0 to inf coprofessors and TAs. Therefore I need to be able to add fields to my form dynamically. I know it is possible through pure Javascript with DOM but most websites and books about Rails tend to tell me to use AJAX and partials. I feel it''s plain stupid to recontact the server just to add a blank <input />. What is the best way? I also need it to work when Javascript isdisabled. Should I use a plain HTML version only that uses one form to add TAs or coprofessors one at a time? Second I''m not sure if my usage of form_for and fields_for is the wisest one. For now, I have one big form (still OK to use I feel) with infos about TAs, coprofessors, periods, places, etc. all in one place. In the back-end of course they are different models so I use a form_for Course and several fields_for (in partials). Should I instead separate it in several pages/views with form_fors in each of them? What the "Railser" way to do it? Thank you for your help and time! -Max --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Marnen Laibow-Koser
2008-Dec-22 03:53 UTC
Re: Form issues : partials + AJAX vs simple JS / separate views + form_fors vs one view and fields_fors
On Dec 21, 3:36 pm, iKs <sadriehmax...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: [...]> First of all, we can have from 0 to inf coprofessors and TAs. > Therefore I need to be able to add fields to my form dynamically. I > know it is possible through pure Javascript with DOM but most websites > and books about Rails tend to tell me to use AJAX and partials. I feel > it''s plain stupid to recontact the server just to add a blank <input />.I would agree with you. The only advantage of recontacting the server is that you can have it spit out a new copy of a partial -- and reinterpret the ERb each time. But judicious use of cloneNode in JS should work just as well.> What is the best way? I also need it to work when Javascript is > disabled. Should I use a plain HTML version only that uses one form to > add TAs or coprofessors one at a time?That''s a usability decision best left to you and your users.> > Second I''m not sure if my usage of form_for and fields_for is the > wisest one. For now, I have one big form (still OK to use I feel) with > infos about TAs, coprofessors, periods, places, etc. all in one place. > In the back-end of course they are different models so I use a > form_for Course and several fields_for (in partials). Should I instead > separate it in several pages/views with form_fors in each of them? > What the "Railser" way to do it?Again, use whatever UI will be best for your users. It''s perfectly OK to use lots of fields_for to get different models onto one form if that''s what the UI calls for.> > Thank you for your help and time! > > -MaxBest, -- Marnen Laibow-Koser marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org http://www.marnen.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---