Hi, I am brand new to Rails and I love it, but I am stuck on something I just can''t figure out. I have table in my database of Pages which are listed in the admin view in an HTML table. Each page has ID Title Content Page_order The HTML table displays: Title Page_order The HTML table has some jQuery attached to it that allows me to sort the rows up and down, and then updates the text inside the Page_order table cells to be in numerical order. In other words: --------------------------------- | Title | Page Order | --------------------------------- | About | 0 | | Contact | 1 | | Pricing | 2 | --------------------------------- Say you want Contact to be at the bottom (since the nav menu on the web site is ordered by page_order). So you drag Pricing above Contact and you''ll see: --------------------------------- | Title | Page Order | --------------------------------- | About | 0 | | Pricing | 1 | | Contact | 2 | --------------------------------- This I can make work. The part I don''t know how to do is send an ajax request to update the database and change the page_order values to reflect the changes. Can someone help? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ar Chron
2008-Nov-10 12:50 UTC
Re: Noob needs help updating a sortable table in the database
Why not defer making changes at the DB level until the person is done with the page. Ye olde Save or Cancel (or just navigate away). An Ajax request and DB update per "fiddle" with a row seems overdone to me, but if your interface doesn''t use an explicit "save" button or something similar, then it could work. As for the Ajax part, I haven''t ventured there myself yet. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
JoeMSak
2008-Nov-10 13:21 UTC
Re: Noob needs help updating a sortable table in the database
Well I''m trying to do it from the list action, so there is no save button, though I could do that. It''s not a bad idea. Maybe enable/ reveal a link_to or button_to after a change is made? On Nov 10, 7:50 am, Ar Chron <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Why not defer making changes at the DB level until the person is done > with the page. Ye olde Save or Cancel (or just navigate away). > > An Ajax request and DB update per "fiddle" with a row seems overdone to > me, but if your interface doesn''t use an explicit "save" button or > something similar, then it could work. > > As for the Ajax part, I haven''t ventured there myself yet. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---