Problem: I have a table for the chosen images (ones marked with a checkbox) and that is working. However, I am trying to implement a drag and drop table and while the dragging and dropping is working, the update is not working. 1) app/views/products/show.html.erb contains the script for the drag and drop table. The id of the table is "sortable1". I am using Jquery UI to create the drag and drop feature for the table. Line 103: $(''#sortable1'').sortable() creates this feature The next lines after Line 103: axis: ''y'', update: function(event, ui) { order = $(this).sortable(''toArray''); alert(order); var id = $(''body'').data(''id''); alert(id); $.post(''/products/'' + id, {''order'': order}); So the chosen images can only be dragged along the y-axis (which works) and now the update method (which i am having trouble with) the variable order includes the array with the html ids for the chosen images (I have them as row1,row2,row3,etc). So changing the 2nd image with the 3rd image would alert me saying "row1, row3, row2" (Because of "alert(order)"). The variable id contains the id of the product which we are looking at (This is done with javascript by retrieving the html attribute "data-id" which i have set as the id of the product). The next part $.post method is a Jquery method that sends data to the server. The first parameter of the $.post method is the url so it sends data to "products/id" (This is how i have it in rails as the url) and the next parameter is the data being sent (in this case, the variable order). Now what i believe is supposed to happen is that i can retrieve "order" in rails by using params[:order]. This is the main problem. params[:order] does not return anything What is the problem here? Attachments: http://www.ruby-forum.com/attachment/7605/show.html.erb -- 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-/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 https://groups.google.com/groups/opt_out.
On 17 July 2012 17:00, Sajidur Rahman <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Problem: I have a table for the chosen images (ones marked with a > checkbox) and that is working. However, I am trying to implement a drag > and drop table and while the dragging and dropping is working, the > update is not working. > > 1) app/views/products/show.html.erb contains the script for the drag and > drop table. The id of the table is "sortable1". I am using Jquery UI to > create the drag and drop feature for the table. > > Line 103: $(''#sortable1'').sortable() creates this feature > > The next lines after Line 103: > axis: ''y'', > update: function(event, ui) { > order = $(this).sortable(''toArray''); > alert(order); > var id = $(''body'').data(''id''); > alert(id); > $.post(''/products/'' + id, {''order'': order}); > > So the chosen images can only be dragged along the y-axis (which works) > and now the update method (which i am having trouble with) > > the variable order includes the array with the html ids for the chosen > images (I have them as row1,row2,row3,etc). So changing the 2nd image > with the 3rd image would alert me saying "row1, row3, row2" (Because of > "alert(order)"). > > The variable id contains the id of the product which we are looking at > (This is done with javascript by retrieving the html attribute "data-id" > which i have set as the id of the product). > > The next part $.post method is a Jquery method that sends data to the > server. The first parameter of the $.post method is the url so it sends > data to "products/id" (This is how i have it in rails as the url) and > the next parameter is the data being sent (in this case, the variable > order). > > Now what i believe is supposed to happen is that i can retrieve "order" > in rails by using params[:order]. This is the main problem. > params[:order] does not return anythingHave a look in development.log to see what params are being passed. That will tell you whether it is the request that is wrong or the action. Colin -- 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 https://groups.google.com/groups/opt_out.
Sajidur Rahman
2012-Jul-17 16:14 UTC
Re: Update feature not working for drag and drop table
Colin Law wrote in post #1069085:> On 17 July 2012 17:00, Sajidur Rahman <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> >> and now the update method (which i am having trouble with) >> The next part $.post method is a Jquery method that sends data to the >> server. The first parameter of the $.post method is the url so it sends >> data to "products/id" (This is how i have it in rails as the url) and >> the next parameter is the data being sent (in this case, the variable >> order). >> >> Now what i believe is supposed to happen is that i can retrieve "order" >> in rails by using params[:order]. This is the main problem. >> params[:order] does not return anything > > Have a look in development.log to see what params are being passed. > That will tell you whether it is the request that is wrong or the > action. > > ColinHow do i efficiently look through development.log? I see a lot of "Started GET ..." -- 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-/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 https://groups.google.com/groups/opt_out.
Colin Law
2012-Jul-17 16:47 UTC
Re: Re: Update feature not working for drag and drop table
On 17 July 2012 17:14, Sajidur Rahman <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1069085: >> On 17 July 2012 17:00, Sajidur Rahman <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> >>> and now the update method (which i am having trouble with) >>> The next part $.post method is a Jquery method that sends data to the >>> server. The first parameter of the $.post method is the url so it sends >>> data to "products/id" (This is how i have it in rails as the url) and >>> the next parameter is the data being sent (in this case, the variable >>> order). >>> >>> Now what i believe is supposed to happen is that i can retrieve "order" >>> in rails by using params[:order]. This is the main problem. >>> params[:order] does not return anything >> >> Have a look in development.log to see what params are being passed. >> That will tell you whether it is the request that is wrong or the >> action. >> >> Colin > > How do i efficiently look through development.log? > > I see a lot of "Started GET ..."Start by running rake log:clear that will empty the log. Then get to the point where you are about to make the failing request. Look in the log to see what is there. Note the line number possibly. Then run the action and look at the log again to see what has been added. Also have a look at the Rails Guide on debugging, it will show you techniques you can use to debug the code. Colin -- 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 https://groups.google.com/groups/opt_out.