The new pragmatic Rails Cookbook has a drag and drop sorting recipe. Does anyone know if this works with 1.0? I''ve followed the recipe (i think), and I can drag but when I drop everything goes back the way it was. It seems that the sort logic doesn''t get invoked. I put this code in my view: <%= sortable_element ''task-list'' , :url => { :action => "sort", :id => @user }, :complete => visual_effect(:highlight, ''task-list'' ) %> which leads to this in the HTML: //<![CDATA[ Sortable.create(''task-list'', {onUpdate:function() {new Ajax.Request(''/tasklists/sort/101'', {asynchronous:true, evalScripts:true, onComplete:function(request) {new Effect.Highlight(''task-list'',{});}, parameters:Sortable.serialize(''task-list'')})}}) //]]> but the sort method doesn''t get invoked on the drop. Any idea why? thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060323/4904b2b4/attachment.html
On 3/23/06, Larry White <ljw1001@gmail.com> wrote:> > The new pragmatic Rails Cookbook has a drag and drop sorting recipe. Does > anyone know if this works with 1.0? > > I''ve followed the recipe (i think), and I can drag but when I drop > everything goes back the way it was. It seems that the sort logic doesn''t > get invoked. > > Larry, this indeed does work with 1.0. Eliminate the easy stuff first--check that you have acts_as_list in your model, a position field in your table, and, of course, javascript_include_tag :defaults somewhere in your view. HTH, Dean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060323/fca6b61c/attachment-0001.html
I have all those things setup. This is my model: class TaskItem < ActiveRecord::Base belongs_to :task belongs_to :person acts_as_list :scope => :person end This is the table: CREATE TABLE task_item ( person_id int4 NOT NULL, "position" int4 NOT NULL, task_id int4 NOT NULL) and the defaults tag is there. It causes three javascript files to be loaded: <script src="/javascripts/effects.js" type="text/javascript"></script> <script src="/javascripts/dragdrop.js" type="text/javascript"></script> <script src="/javascripts/controls.js" type="text/javascript"></script> Any ideas on what to try next? On 3/23/06, Howard Roberts <hdean.roberts@gmail.com> wrote:> > > > On 3/23/06, Larry White <ljw1001@gmail.com> wrote: > > > > The new pragmatic Rails Cookbook has a drag and drop sorting recipe. > > Does anyone know if this works with 1.0? > > > > I''ve followed the recipe (i think), and I can drag but when I drop > > everything goes back the way it was. It seems that the sort logic doesn''t > > get invoked. > > > > Larry, this indeed does work with 1.0. Eliminate the easy stuff first-- > check that you have acts_as_list in your model, a position field in your > table, and, of course, javascript_include_tag :defaults somewhere in your > view. > > HTH, > Dean > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/e7011751/attachment-0001.html
Ok - it was working. I had been grabbing the list items by the list item symbol, and it worked for dragging but not dropping. As long as I grab the item by its name, the drop works - strange. Thanks for your help. On 3/23/06, Larry White <ljw1001@gmail.com> wrote:> > I have all those things setup. This is my model: > > class TaskItem < ActiveRecord::Base > belongs_to :task > belongs_to :person > acts_as_list :scope => :person > end > > This is the table: > > CREATE TABLE task_item > ( person_id int4 NOT NULL, > "position" int4 NOT NULL, > task_id int4 NOT NULL) > > and the defaults tag is there. It causes three javascript files to be > loaded: > > <script src="/javascripts/effects.js" type> "text/javascript"></script> > <script src="/javascripts/dragdrop.js" > type="text/javascript"></script> > <script > src="/javascripts/controls.js" type="text/javascript"></ > script> > > Any ideas on what to try next? > > > > On 3/23/06, Howard Roberts < hdean.roberts@gmail.com> wrote: > > > > > On 3/23/06, Larry White <ljw1001@gmail.com > wrote: > > > > The new pragmatic Rails Cookbook has a drag and drop sorting recipe. > > Does anyone know if this works with 1.0? > > > > I''ve followed the recipe (i think), and I can drag but when I drop > > everything goes back the way it was. It seems that the sort logic doesn''t > > get invoked. > > > > Larry, this indeed does work with 1.0. Eliminate the easy stuff first-- > check that you have acts_as_list in your model, a position field in your > table, and, of course, javascript_include_tag :defaults somewhere in your > view. > > HTH, > Dean > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/a7cc077e/attachment.html