I''m not sure if this can be done, but I though I would ask. Lets say I have two sortable lists in which items can be moved back and forth. One list has some numbers, while the other one is empty. Once moved from list A to list B, I want the value of the number to increase by one, and when moved back, I want it to decrease by one. I was think of using onUpdate, but I don''t see how I could make that work. I''m using PHP by the way. Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
frank a écrit :> I''m not sure if this can be done, but I though I would ask. Lets say I > have two sortable lists in which items can be moved back and forth. One > list has some numbers, while the other one is empty. Once moved from > list A to list B, I want the value of the number to increase by one, > and when moved back, I want it to decrease by one. I was think of using > onUpdate, but I don''t see how I could make that work. I''m using PHP by > the way.Your onUpdate event handler (which is only triggered when the contained items actually changed, btw) for each list will receive your container as an argument. You may then iterate through its contained items (Prototype provides plenty of helpers there) to look for the new one, and depending on the list you''re reacting to, either add or subtract from its number. To identify an item as the "new one" though, you''ll probably need to use custom properties on the DOM nodes for the items. script.aculo.us does not provide the changed item as an argument. *Therefore* look into the onChange event handler, which is called whenever the elements'' order changes, and receives the *changed element* as an argument. However, this will be triggered for in-list reordering as well. ''HTH -- 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 -~----------~----~----~----~------~----~------~--~---
How can the value after the underscore in the id of the item that just got moved be accessed? To clarify, this is the number that is contained in the array created by Sortable.serialize. Is there a way that this can be accessed on the same page without having to do an Ajax.Request? I think I have another way of accomplishing what I asked before but I would need this value. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
The only way that I''ve been able to get the IDs is like so: onChange: function(){ var text = Sortable.serialize("list"); var first_id = (text.substr(8,4)); var second_id = (text.substr(21,4)); } In this case the lengths of the IDs is 4 digits. The problem with the above is that you can''t get the ID of the item that was added to the list the most recently. I''m sure there''s a better way... --~--~---------~--~----~------------~-------~--~----~ 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 :> onChange: function(){Since onChange takes the changed element as an argument, and there is a "_" in the ID, try this: onChange: function(elt) { var suffix = elt.id.split(''_'')[1]; //... } ''Should work. -- Christophe Porteneuve aka TDD 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 -~----------~----~----~----~------~----~------~--~---
Christophe, That works perfectly. Thank you very much for your help. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---