If you have two sortable lists on one page, how can you update them both? I''ve tired using parameters : Sortable.serialize(list1) + Sortable.serialize(list2) but that was futile. How can this be done? 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 -~----------~----~----~----~------~----~------~--~---
Hello Frank, frank a écrit :> If you have two sortable lists on one page, how can you update them > both? I''ve tired using parameters : Sortable.serialize(list1) + > Sortable.serialize(list2) but that was futile. How can this be done?I fail to see how this would be futile, except you might need a separator (&) between the two resulting strings. Also, are you sure you implement the whole workflow? 1. Your user drags from one list to another 2. Both lists'' onUpdate events are triggered 3. You react to one of those (both is useless, I guess) by serializing both to a unique parameter string 4. You send this string as parameters on a Ajax.Request call 5. Your server side processes the state This requires, among other things, that you follow the sortable items'' ID guidelines from the wiki: "anyprefix_actualIdValue". ''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 -~----------~----~----~----~------~----~------~--~---
Thank you for your reply.
Having the ability to drag items from one list to another is the
ultimate goal, but right now I''m just trying to have two independant
lists on the same page. My update function looks like this:
function updateOrder()
{
var options = {
method : ''post'',
parameters :
Sortable.serialize(''list1'') +
Sortable.sequence(''list2'')
};
new Ajax.Request(''queries.php'', options );
}
On the receiving end, I have a function which updates the database that
should run once for each list. So queries.php looks like this:
function processOrder($key) {
$order = 1;
foreach ($_POST[$key] as $item_id) {
$query = "UPDATE items SET order = ''$order''
WHERE item_id ''$item_id''";
$result = mysql_query ($query);
$order++;
}
}
processOrder(''list1'');
processOrder(''list2'');
Could you post the link for the "anyprefix_actualIdValue" wiki - I
searched for it but couldn''t find it.
--~--~---------~--~----~------------~-------~--~----~
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.serialize(''list1'') + Sortable.sequence(''list2'')There will probably be a missing ''&'' between your two serializations. Also, why do you manually go to sequence in the second part, instead of relying on serialize to choose as per its internal logic?> function processOrder($key) { > ... > foreach ($_POST[$key] as $item_id) { > ... > processOrder(''list1''); > processOrder(''list2'');This is correct, since the syntax by serialize: list1[]=..&list1[]=...&list2[]=...&list2[]=... Will indeed produce arrays for $_POST[''list1''] / $_POST[''list2'']. As for the wiki page: http://wiki.script.aculo.us/scriptaculous/show/Sortable.serialize => The "important" note in the middle, and the code example below. ''HTH -- 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 -~----------~----~----~----~------~----~------~--~---
I don''t know if this was just code you whipped up to illustrate what it is you are trying to accomplish or if this is actual code you have running, but I just wanted to send a quick message to make sure that you know that code like this is _potentially_ very dangerous. Simply accepting client input and dropping it directly into an SQL query is a quick way to find yourself with an XSS vulnerabilty. I know you''re using PHP and they have all kinds of ridiculous little ''magic'' protection functions to auto-escape variables and what-not, but I think that relying on the PHP development team to protect my data is a little too risky to do. So, there you go. You can write me back if you want me to explain this in greater detail. I don''t want to ramble on about this if you were just trying to make a point. But, better safe than sorry. -Eric On 9/27/06, frank <FrankWitt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Thank you for your reply. > > Having the ability to drag items from one list to another is the > ultimate goal, but right now I''m just trying to have two independant > lists on the same page. My update function looks like this: > > function updateOrder() > { > var options = { > method : ''post'', > parameters : > Sortable.serialize(''list1'') + Sortable.sequence(''list2'') > }; > > new Ajax.Request(''queries.php'', options ); > } > > On the receiving end, I have a function which updates the database that > should run once for each list. So queries.php looks like this: > > function processOrder($key) { > > $order = 1; > > foreach ($_POST[$key] as $item_id) { > > $query = "UPDATE items SET order = ''$order'' WHERE item_id > ''$item_id''"; > $result = mysql_query ($query); > > $order++; > } > } > > processOrder(''list1''); > processOrder(''list2''); > > > Could you post the link for the "anyprefix_actualIdValue" wiki - I > searched for it but couldn''t find it. > > > > >-- Eric Ryan Harrison, Developer model13 Designs --~--~---------~--~----~------------~-------~--~----~ 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,
How could the order of the second part be determined if you don''t
serialize it? It looks like I have it working with
Sortable.serialize(''list1'') + ''&'' +
Sortable.serialize(''list2'') as the
parameter, and
function processlist($num1,$num2) {
$key1 = ''list''.$num1;
$key2 = ''list''.$num2;
$ranking = 1;
foreach ($_POST[$key1] as $item_id) {
$query = "UPDATE items SET item_order = ''$ranking'',
list_id = ''1''
WHERE item_id = ''$item_id''";
$result = mysql_query ($query);
$ranking++;
}
$ranking = 1;
foreach ($_POST[$key2] as $item_id) {
$query = "UPDATE items SET item_order = ''$ranking'',
list_id = ''2''
WHERE item_id = ''$item_id''";
$result = mysql_query ($query);
$ranking++;
}
}
processlist(''1'',''2'');
as the backend.
--~--~---------~--~----~------------~-------~--~----~
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 a écrit :> Christophe, > > How could the order of the second part be determined if you don''t > serialize it? It looks like I have it working withI don''t say "don''t serialize it". I say "use .serialize, not .sequence".> Sortable.serialize(''list1'') + ''&'' + Sortable.serialize(''list2'') as theGood. Why you changed the backend, I can''t guess. The former one should have worked just as well! -- 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 -~----------~----~----~----~------~----~------~--~---
Hey, Oh, I see what you mean - I''m not sure why I had that there before. I changed the backend because I wanted the processlist function to be called only once. Thanks 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 -~----------~----~----~----~------~----~------~--~---