Hi, I have a project that involves creating a sortable list, which the user is supposed to re-order, then submit with a submit button. Unfortunately, the only way I''ve been able to do this involves hitting the server every time a change is made to the order of the list, and then just setting a "submitted" flag when they try to submit. This is highly suboptimal. Does anyone know how I can actually submit the items only when they finally hit that submit button/link? I''ve tried a million things, but all of them are either really distasteful (creating a form with a hidden field and updating its contents), or mindlessly complex. This can''t be _that_ uncommon of a use case. Can anyone help? TIA, Kurt --~--~---------~--~----~------------~-------~--~----~ 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 can only offer this site as a sample http://www.gregphoto.net/sortable/index.php it sounds to me like you are triggering an ajax.updater in the onUpdate section, sometimes this is wanted, sometimes its not On Nov 19, 2007 11:32 PM, Kurt Dresner <kurt.dresner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > I have a project that involves creating a sortable list, which the > user is supposed to re-order, then submit with a submit button. > > Unfortunately, the only way I''ve been able to do this involves hitting > the server every time a change is made to the order of the list, and > then just setting a "submitted" flag when they try to submit. > > This is highly suboptimal. > > Does anyone know how I can actually submit the items only when they > finally hit that submit button/link? > > I''ve tried a million things, but all of them are either really > distasteful (creating a form with a hidden field and updating its > contents), or mindlessly complex. This can''t be _that_ uncommon of a > use case. Can anyone help? > > TIA, > > Kurt > > >--~--~---------~--~----~------------~-------~--~----~ 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 definitely can turn off the Ajax.Updater, but what I need to be able to do is submit the information from Sortable.serialize some other way. I am not very good with JavaScript, but is there some way to change the following code (generated by link_to): <a href="/choices/save/5" onclick="var f = document.createElement(''form''); f.style.display ''none''; this.parentNode.appendChild(f); f.method = ''POST''; f.action = this.href;f.submit();return false;">save choices</a> So that somehow the return value of Sortable.serialize(''choice_list'') gets submitted too? I tried changing the action to this.href + Sortable.serialize(''choice_list''), but it didn''t have any effect. It seems there should be a way to tell rails "I want you to submit the stuff generated by the following JavaScript: ". But I am either too blind to find it or it doesn''t exist (either is likely). -Kurt On Nov 20, 10:11 am, "Brian Williams" <brianw1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i can only offer this site as a samplehttp://www.gregphoto.net/sortable/index.php > > it sounds to me like you are triggering an ajax.updater in the onUpdate > section, sometimes this is wanted, sometimes its not > > On Nov 19, 2007 11:32 PM, Kurt Dresner <kurt.dres...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi, > > > I have a project that involves creating a sortable list, which the > > user is supposed to re-order, then submit with a submit button. > > > Unfortunately, the only way I''ve been able to do this involves hitting > > the server every time a change is made to the order of the list, and > > then just setting a "submitted" flag when they try to submit. > > > This is highly suboptimal. > > > Does anyone know how I can actually submit the items only when they > > finally hit that submit button/link? > > > I''ve tried a million things, but all of them are either really > > distasteful (creating a form with a hidden field and updating its > > contents), or mindlessly complex. This can''t be _that_ uncommon of a > > use case. Can anyone help? > > > TIA, > > > Kurt--~--~---------~--~----~------------~-------~--~----~ 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 didn''t say to turn the updater off complete, just don''t put it in the onUpdate. the example on the link in my previous post should have had everything you needed. you need to have the form you are creating have an onsubmit function that calls a function that grabs the serialized data and submits it via the updater On Nov 20, 2007 1:06 PM, Kurt Dresner <kurt.dresner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I definitely can turn off the Ajax.Updater, but what I need to be able > to do is submit the information from Sortable.serialize some other > way. I am not very good with JavaScript, but is there some way to > change the following code (generated by link_to): > > <a href="/choices/save/5" > onclick="var f = document.createElement(''form''); f.style.display > ''none''; > this.parentNode.appendChild(f); f.method = ''POST''; > f.action = this.href;f.submit();return false;">save > choices</a> > > So that somehow the return value of Sortable.serialize(''choice_list'') > gets submitted too? I tried changing the action to this.href + > Sortable.serialize(''choice_list''), but it didn''t have any effect. > > It seems there should be a way to tell rails "I want you to submit the > stuff generated by the following JavaScript: ". > > But I am either too blind to find it or it doesn''t exist (either is > likely). > > -Kurt > > On Nov 20, 10:11 am, "Brian Williams" <brianw1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > i can only offer this site as a > samplehttp://www.gregphoto.net/sortable/index.php > > > > it sounds to me like you are triggering an ajax.updater in the onUpdate > > section, sometimes this is wanted, sometimes its not > > > > On Nov 19, 2007 11:32 PM, Kurt Dresner <kurt.dres...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > Hi, > > > > > I have a project that involves creating a sortable list, which the > > > user is supposed to re-order, then submit with a submit button. > > > > > Unfortunately, the only way I''ve been able to do this involves hitting > > > the server every time a change is made to the order of the list, and > > > then just setting a "submitted" flag when they try to submit. > > > > > This is highly suboptimal. > > > > > Does anyone know how I can actually submit the items only when they > > > finally hit that submit button/link? > > > > > I''ve tried a million things, but all of them are either really > > > distasteful (creating a form with a hidden field and updating its > > > contents), or mindlessly complex. This can''t be _that_ uncommon of a > > > use case. Can anyone help? > > > > > TIA, > > > > > Kurt > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
As it turns out, this disgusting piece of kludge did the trick quite nicely. (helper method) def link_to_remote_send_sortable(*args) unless args[1].is_a? Hash and args[1][:submit] # nil is _not_ a Hash raise ArgumentError, "link_to_remote_send_sortable must have the DOM ID of a Sortable element specified via :submit => sortable_element" end link_to_remote(*args).gsub(/parameters:Form.serialize\(''#{args[1] [:submit]}''\)/) { |match| match.sub(''Form'',''Sortable'') } end -Kurt On Nov 20, 12:36 pm, "Brian Williams" <brianw1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I didn''t say to turn the updater off complete, just don''t put it in the > onUpdate. > > the example on the link in my previous post should have had everything you > needed. > > you need to have the form you are creating have an onsubmit function that > calls a function that grabs the serialized data and submits it via the > updater > > On Nov 20, 2007 1:06 PM, Kurt Dresner <kurt.dres...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I definitely can turn off the Ajax.Updater, but what I need to be able > > to do is submit the information from Sortable.serialize some other > > way. I am not very good with JavaScript, but is there some way to > > change the following code (generated by link_to): > > > <a href="/choices/save/5" > > onclick="var f = document.createElement(''form''); f.style.display > > ''none''; > > this.parentNode.appendChild(f); f.method = ''POST''; > > f.action = this.href;f.submit();return false;">save > > choices</a> > > > So that somehow the return value of Sortable.serialize(''choice_list'') > > gets submitted too? I tried changing the action to this.href + > > Sortable.serialize(''choice_list''), but it didn''t have any effect. > > > It seems there should be a way to tell rails "I want you to submit the > > stuff generated by the following JavaScript: ". > > > But I am either too blind to find it or it doesn''t exist (either is > > likely). > > > -Kurt > > > On Nov 20, 10:11 am, "Brian Williams" <brianw1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > i can only offer this site as a > > samplehttp://www.gregphoto.net/sortable/index.php > > > > it sounds to me like you are triggering an ajax.updater in the onUpdate > > > section, sometimes this is wanted, sometimes its not > > > > On Nov 19, 2007 11:32 PM, Kurt Dresner <kurt.dres...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi, > > > > > I have a project that involves creating a sortable list, which the > > > > user is supposed to re-order, then submit with a submit button. > > > > > Unfortunately, the only way I''ve been able to do this involves hitting > > > > the server every time a change is made to the order of the list, and > > > > then just setting a "submitted" flag when they try to submit. > > > > > This is highly suboptimal. > > > > > Does anyone know how I can actually submit the items only when they > > > > finally hit that submit button/link? > > > > > I''ve tried a million things, but all of them are either really > > > > distasteful (creating a form with a hidden field and updating its > > > > contents), or mindlessly complex. This can''t be _that_ uncommon of a > > > > use case. Can anyone help? > > > > > TIA, > > > > > Kurt--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---