I have three sortable lists on a page. I am trying to get the lists to work as such: - Each list has one, and onlyu one element. - If a item from list 1 is dragged to list 2, they swap. -After a swap, a call back function delivers an ajax url to my server (where I call some prewritten functions) I found some code that looks like it could be repurposed for this: Sortable.create("list_to_sort", { onUpdate: function() { new Ajax.Request("my_data_updater.php", { method: "get", parameters: { data: Sortable.serialize("list_to_sort") } } ); } } ); The question is, how do I get the id of the source and destination items in this little transaction? Thanks for any assistance! --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Take a look at the parameter that''s passed to onUpdate(), and see if that helps. ... onUpdate: function (element) { ... You may also want to take a look at the SortableObserver class in dragdrop.js, and do something like that. The Sortable.serialize() and Sortable.sequence() functions may come in handy. TAG On Aug 29, 2007, at 5:22 PM, Steve wrote:> > I have three sortable lists on a page. I am trying to get the lists to > work as such: > > - Each list has one, and onlyu one element. > - If a item from list 1 is dragged to list 2, they swap. > -After a swap, a call back function delivers an ajax url to my server > (where I call some prewritten functions) > > I found some code that looks like it could be repurposed for this: > > Sortable.create("list_to_sort", > { > onUpdate: function() > { > new Ajax.Request("my_data_updater.php", > { > method: "get", > parameters: { data: Sortable.serialize("list_to_sort") } > } > ); > } > } > ); > > The question is, how do I get the id of the source and destination > items in this little transaction? > > Thanks for any assistance! > > > >--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
I get a blank page on the scriptaculous site for sortables. Is there any kind of API reference around besides on that site? Don''t see anything in the scriptaculous downloads. Without it, what I am reading is greek because this is my first outing with Scriptaculous... On Aug 29, 7:03 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote:> Take a look at the parameter that''s passed to onUpdate(), and see if > that helps. > > ... > onUpdate: function (element) { > ... > > You may also want to take a look at the SortableObserver class in > dragdrop.js, and do something like that. The Sortable.serialize() and > Sortable.sequence() functions may come in handy. > > TAG > > On Aug 29, 2007, at 5:22 PM, Steve wrote: > > > > > > > I have three sortable lists on a page. I am trying to get the lists to > > work as such: > > > - Each list has one, and onlyu one element. > > - If a item from list 1 is dragged to list 2, they swap. > > -After a swap, a call back function delivers an ajax url to my server > > (where I call some prewritten functions) > > > I found some code that looks like it could be repurposed for this: > > > Sortable.create("list_to_sort", > > { > > onUpdate: function() > > { > > new Ajax.Request("my_data_updater.php", > > { > > method: "get", > > parameters: { data: Sortable.serialize("list_to_sort") } > > } > > ); > > } > > } > > ); > > > The question is, how do I get the id of the source and destination > > items in this little transaction? > > > Thanks for any assistance!- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
http://wiki.script.aculo.us/scriptaculous/show/Sortable.create The documentation of the callbacks could be improved (e.g. tell what the parameters are!), but hey--it''s a wiki. When you figure it out, update the docs! onUpdate(element) is passed an element... I suspect it''s a reference to the container element, which allows you to do this: onUpdate: function (element) { console.log(Sortable.serialize(element)); // ... } http://wiki.script.aculo.us/scriptaculous/show/Sortable.serialize TAG On Aug 29, 2007, at 7:28 PM, Steve wrote:> > I get a blank page on the scriptaculous site for sortables. Is there > any kind of API reference around besides on that site? Don''t see > anything in the scriptaculous downloads. Without it, what I am reading > is greek because this is my first outing with Scriptaculous... > > > > On Aug 29, 7:03 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote: >> Take a look at the parameter that''s passed to onUpdate(), and see if >> that helps. >> >> ... >> onUpdate: function (element) { >> ... >> >> You may also want to take a look at the SortableObserver class in >> dragdrop.js, and do something like that. The Sortable.serialize() and >> Sortable.sequence() functions may come in handy. >> >> TAG >> >> On Aug 29, 2007, at 5:22 PM, Steve wrote: >> >> >> >> >> >>> I have three sortable lists on a page. I am trying to get the >>> lists to >>> work as such: >> >>> - Each list has one, and onlyu one element. >>> - If a item from list 1 is dragged to list 2, they swap. >>> -After a swap, a call back function delivers an ajax url to my >>> server >>> (where I call some prewritten functions) >> >>> I found some code that looks like it could be repurposed for this: >> >>> Sortable.create("list_to_sort", >>> { >>> onUpdate: function() >>> { >>> new Ajax.Request("my_data_updater.php", >>> { >>> method: "get", >>> parameters: { data: Sortable.serialize("list_to_sort") } >>> } >>> ); >>> } >>> } >>> ); >> >>> The question is, how do I get the id of the source and destination >>> items in this little transaction? >> >>> Thanks for any assistance!- Hide quoted text - >> >> - Show quoted text - > > > >--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
I am not certain these are answering the core question. Maybe restating it a different way would help; I have two lists with ids aList and bList. If I drag an element from aList to bList, how to I access the destination list id and the origin list id. If I can get that one bit of information I can muddle through the rest. Ultimately, each list is intended to hold one and only one element. So, I will want to swape the list items on drop. Makse sense? On Aug 29, 7:41 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote:> http://wiki.script.aculo.us/scriptaculous/show/Sortable.create > > The documentation of the callbacks could be improved (e.g. tell what > the parameters are!), but hey--it''s a wiki. When you figure it out, > update the docs! > > onUpdate(element) is passed an element... I suspect it''s a reference > to the container element, which allows you to do this: > > onUpdate: function (element) { > console.log(Sortable.serialize(element)); > // ... > > } > > http://wiki.script.aculo.us/scriptaculous/show/Sortable.serialize > > TAG > > On Aug 29, 2007, at 7:28 PM, Steve wrote: > > > > > > > I get a blank page on the scriptaculous site for sortables. Is there > > any kind of API reference around besides on that site? Don''t see > > anything in the scriptaculous downloads. Without it, what I am reading > > is greek because this is my first outing with Scriptaculous... > > > On Aug 29, 7:03 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote: > >> Take a look at the parameter that''s passed to onUpdate(), and see if > >> that helps. > > >> ... > >> onUpdate: function (element) { > >> ... > > >> You may also want to take a look at the SortableObserver class in > >> dragdrop.js, and do something like that. The Sortable.serialize() and > >> Sortable.sequence() functions may come in handy. > > >> TAG > > >> On Aug 29, 2007, at 5:22 PM, Steve wrote: > > >>> I have three sortable lists on a page. I am trying to get the > >>> lists to > >>> work as such: > > >>> - Each list has one, and onlyu one element. > >>> - If a item from list 1 is dragged to list 2, they swap. > >>> -After a swap, a call back function delivers an ajax url to my > >>> server > >>> (where I call some prewritten functions) > > >>> I found some code that looks like it could be repurposed for this: > > >>> Sortable.create("list_to_sort", > >>> { > >>> onUpdate: function() > >>> { > >>> new Ajax.Request("my_data_updater.php", > >>> { > >>> method: "get", > >>> parameters: { data: Sortable.serialize("list_to_sort") } > >>> } > >>> ); > >>> } > >>> } > >>> ); > > >>> The question is, how do I get the id of the source and destination > >>> items in this little transaction? > > >>> Thanks for any assistance!- Hide quoted text - > > >> - Show quoted text -- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
On Aug 29, 2007, at 8:43 PM, Steve wrote:> I am not certain these are answering the core question.They are. I''m pretty sure I get what you want. I''m trying to give you the tools to craft a solution, rather than the full solution. Make something similar to the SortableObserver object in dragdrop.js. Depending on how whether you want the behavior to trigger when the drag finishes rather than mid-drag, you may want to use onEnd rather than onUpdate. It could be as simple as: Draggables.addObserver({ onEnd: function (eventName, draggable, event) { //Do stuff } }); You''ll need to get the contents of each Sortable, and figure out which ones need to change. Use Sortable.serialize or Sortable.sequence for that. Best of luck! TAG --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Would just using draggables/droppables outright work? Like in the Cart example? Might be able to avoid the whole serialization thing then. On Aug 29, 9:43 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote:> On Aug 29, 2007, at 8:43 PM, Steve wrote: > > > I am not certain these are answering the core question. > > They are. I''m pretty sure I get what you want. I''m trying to give > you the tools to craft a solution, rather than the full solution. > > Make something similar to the SortableObserver object in > dragdrop.js. Depending on how whether you want the behavior to > trigger when the drag finishes rather than mid-drag, you may want to > use onEnd rather than onUpdate. It could be as simple as: > Draggables.addObserver({ > onEnd: function (eventName, draggable, event) { > //Do stuff > } > > }); > > You''ll need to get the contents of each Sortable, and figure out > which ones need to change. Use Sortable.serialize or > Sortable.sequence for that. > > Best of luck! > > TAG--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---