Joe
2009-Nov-20 05:13 UTC
sortable_element helper -- How do I prevent round trip to server?
I''m using the sortable_element helper method, and for my app I want to use a javascript snippet update the "position" field without going to the server and saving the data right away. Other things on the page could be changing and the re-order needs to be a quick, lite action. My the drag-to-sort works fine, and the JS function I call on complete re-calculates the positions just fine, but even if I don''t specify a value for the URL it still makes the roundtrip to the server. How can I prevent this? <%= sortable_element :line_items, :tag => ''div'', :ghosting => true, :complete => "sortLineItems()" %> -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.
Scott Johnson
2009-Nov-20 19:01 UTC
Re: sortable_element helper -- How do I prevent round trip to server?
I''m not sure why an asynchronous roundtrip to the server is not quick and light. Even if the server takes a while to respond, the user doesn''t have to wait for that response, and in fact shouldn''t even realize anything is still pending. On Nov 19, 9:13 pm, Joe <j...-WSbigQczdccj0o55a+Ij8ljMPmZJtkid@public.gmane.org> wrote:> I''m using the sortable_element helper method, and for my app I want to > use a javascript snippet update the "position" field without going to > the server and saving the data right away. Other things on the page > could be changing and the re-order needs to be a quick, lite action. > > My the drag-to-sort works fine, and the JS function I call on complete > re-calculates the positions just fine, but even if I don''t specify a > value for the URL it still makes the roundtrip to the server. > > How can I prevent this? > > <%= sortable_element :line_items, :tag => ''div'', :ghosting => > true, :complete => "sortLineItems()" %>-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.
Joe McGlynn
2009-Nov-20 19:19 UTC
RE: Re: sortable_element helper -- How do I prevent round trip to server?
It take about 1 second locally -- but there is no reason for it to make the round trip. Calling my JS method using oncomplete means that the re-sort doesn''t happen until after the roundtrip. I''m doing a render :nothing on the server. With Mongrel in a production env this would probably be faster -- I just don''t want to make the trip for No Reason. Joe -----Original Message----- From: Scott Johnson [mailto:scott-wIW8SF+lElu2kH9Ulgv/9g@public.gmane.org] Sent: Friday, November 20, 2009 11:01 AM To: Ruby on Rails: Talk Subject: [Rails] Re: sortable_element helper -- How do I prevent round trip to server? I''m not sure why an asynchronous roundtrip to the server is not quick and light. Even if the server takes a while to respond, the user doesn''t have to wait for that response, and in fact shouldn''t even realize anything is still pending. On Nov 19, 9:13 pm, Joe <j...-WSbigQczdccj0o55a+Ij8ljMPmZJtkid@public.gmane.org> wrote:> I''m using the sortable_element helper method, and for my app I want to > use a javascript snippet update the "position" field without going to > the server and saving the data right away. Other things on the page > could be changing and the re-order needs to be a quick, lite action. > > My the drag-to-sort works fine, and the JS function I call on complete > re-calculates the positions just fine, but even if I don''t specify a > value for the URL it still makes the roundtrip to the server. > > How can I prevent this? > > <%= sortable_element :line_items, :tag => ''div'', :ghosting => > true, :complete => "sortLineItems()" %>-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.