I''m not sure if this can be done, but I thought I''d ask anyways. I have some names contained in a sortable list with each name having some more details to it. It looks something like this: Name 1 - Item 1 - Item 2 - Item 3 Name 2 - Item 4 - Item 5 Name 3 - Item 6 Right now I have it set up so that when you drag the name from one list to another, you are prompted with the items belonging to it. I have it like so: Sortable.create(''names'', {tag:''div'',containment:[''names'',''items'']}); Sortable.create(''items'', {tag:''div'',dropOnEmpty:true,containment:[''names'',''items''], constraint:false, onUpdate:function(){new Ajax.Updater(''items_area'', ''item file'', {onComplete:function(){ new (''items'');}, parameters:Sortable.serialize(''items'')})}}) The problem arises when I want to have the returned items contained in a sortable list. I''ve tried returning the names in a list and having a sortable for them, but that didn''t work. I''ve tried initializing the sortable before anything is returned but that didn''t work either. Can this be done? I hope that all made sense. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hey Frank! frank a écrit :> Sortable.create(''names'', {tag:''div'',containment:[''names'',''items'']}); > Sortable.create(''items'', > {tag:''div'',dropOnEmpty:true,containment:[''names'',''items''], > constraint:false, onUpdate:function(){new Ajax.Updater(''items_area'', > ''item file'', {onComplete:function(){ new (''items'');}, > parameters:Sortable.serialize(''items'')})}})I assume this "new(''items'')" is actually a "Sortable.create(''items'')", because AFAIK, "new(''items'')" doesn''t mean a thing.> The problem arises when I want to have the returned items contained in > a sortable list. I''ve tried returning the names in a list and having a > sortable for them, but that didn''t work. I''ve tried initializing the > sortable before anything is returned but that didn''t work either. Can > this be done? I hope that all made sense.Hmm... This could get ugly, especially as by doing so, your draggables/droppables ref''counting is not done properly (you don''t unregister draggables and, more importantly, droppables, as you replace contents parts). Sortable has an experimental "tree" mode, that you can try to figure out from the source. I believe it is expressly intended for stuff like that. You should check it out. Maybe Thomas can chime in about this? -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> I assume this "new(''items'')" is actually a "Sortable.create(''items'')", > because AFAIK, "new(''items'')" doesn''t mean a thing.You''re right, it does''t mean anything. I tried to modify the source from this: http://demo.script.aculo.us/ajax/sortable_elements to make it work.> Hmm... This could get ugly, especially as by doing so, your > draggables/droppables ref''counting is not done properly (you don''t > unregister draggables and, more importantly, droppables, as you replaceHow would you accomplish this?> Sortable has an experimental "tree" mode, that you can try to figure out > from the source. I believe it is expressly intended for stuff like > that. You should check it out.I couldn''t find anything about this on the scriptaculous site. Just to clarify a bit, right now the processing script returns some values in a list which relate to the name that was dragged. This independent list is placed into the ''items_area'' div. I would like to be able to sort these values which do not rely anymore on the initial sortable list. It should work like this: You are shown two sortable lists with one of them having a list of names while the other one is empty. Names - Bob - John Empty You have the ability to drag the names from the Names list to the Empty list. When you do so, the processing script recieves the array containing the information pertaining to the Empty list. So if you dragged Bob to the Empty list, the processing script would do something with the value of ''Bob'' and return some information relating to it. This information would be placed into an unrelated list which also has the ability to be sorted. It would look like this: Names - John Empty - Bob Details -Height: 6'' -Weight: 180lbs The Details list would now have the ability to be sorted amongst itself. When ''Bob'' is dragged back from Empty to Names, the Details list would dissapear. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hmm... The part I don''t understand is that if I have <div id="details"> <div id="item_1">Item 1</div> <div id="item_2">Item 2</div> </div> Sortable.create(''details'', {tag:''div''}); on the page with ''details'' being the div in which the results are returned everything works fine. But as soon as I return any info, even if it''s the same as above, the list is no longer sortable. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hmm... The part I don''t understand is that if I have <div id="details"> <div id="item_1">Item 1</div> <div id="item_2">Item 2</div> </div> Sortable.create(''details'', {tag:''div''}); on the page with ''details'' being the div in which the results are returned everything works fine. But as soon as I return any info, even if it''s the same as above, the list is no longer sortable. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hey Frank, Well, from your example scenario, there''s no *list within a list* anywhere. There are two flat lists, unembedded, strictly independent from each other. What I suggest is this: - Create all three lists from the start, make the first two sortable. - React to changes in the 2nd list by: a) invoking Sortable.destroy on your 3rd list b) invoking a Ajax.Updater on your 3rd list with the proper params c) using the A.U''s onComplete callback, make the new list sortable by calling Sortable.create on it (which is required for all elements in it to become draggables, etc.) The trick is, Sortable.destroy will not do a thing if the list wasn''t sortable yet, otherwise it will unregister all related draggables/droppables, which is perfect for your needs. Step c) will recreate all necessary drag/drop/sort mechanisms on the updated list. Depending on your styling, you might want to make the 3rd list hidden with an inline "display: none" style attribute, and add extra steps around a)-c) that toggle it. To react to changes in the 2nd list, when you make it sortable, bind the onUpdate callback (invoked every time the list''s contents or order changes). -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---