I can show you how I do this in PHP, not Perl but a cousin.
<?php
require_once('config.inc.php');
foreach($_POST['sort_list'] as $k=>$v){
if($product = ActiveRecord::FindById('products',$v)) {
$product->position = $k+1;
$product->save();
}
}
print 'finished';
?>
This relies on the following HTML:
<div id="message" style="display:none"></div>
<ul id="sort_list">
<li id="product_1">Product 1</li>
...etc... (each product ID'd according to the rules for sortable)
</ul>
And JavaScript:
Sortable.create('sort_list',{
onUpdate: function(){
new Ajax.Request('ajax_update_position.php',{
parameters: Sortable.serialize('sort_list'),
evalScripts:true,
onCreate: function(transport){
$('message').show().update('<img
src="Resources/spinner.gif" height="16" width="16" alt="" />');
},
onComplete: function(transport){
$('message').update('Changes saved!');
new Effect.Highlight('message');
new Effect.Fade('message',{delay:1});
}
})
}
});
This is a really old example, I would probably write this all much more cleanly
now (and I'd be doing it in Rails anyway) but this works very solidly.
Walter
On Mar 10, 2012, at 1:52 PM, Dave wrote:
> Hi,
> I began experimenting with the 'sortables' and really like the 4th
> version. I'm extracting the list from a MySql db to build the list and
> all works fine but how do I get the results back into the database
> after the sort? I'm using perl--need this for a cgi script. Thanx.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.