Hi, I am having a problem with sortables. I can drag the images around, but it doesn''t update my records in my database... I''m not sure if it''s even calling the file... here is my code: <div id="imageFloatContainer"> <img src="http://fashdax.com/gallery/I/2005/01/01/thumb/3.jpg" id="3"> <img src="http://fashdax.com/gallery/I/2005/01/01/thumb/4.jpg" id="4"> <img src="http://fashdax.com/gallery/I/2005/01/01/thumb/5.jpg" id="5"> </div> <script type="text/javascript"> function updateOrder(){ var options = { method : ''post'', parameters : Sortable.serialize(''imageFloatContainer'') }; new Ajax.Request(''http://www.fashdax.com/gallery_update.php'', options); } Sortable.create(''imageFloatContainer'', {tag:''img'',overlap:''horizontal'',constraint: false, onUpdate : updateOrder}); </script> PHP FILE: <? include(config.php); mysql_connect("$host","$user","$pass") or die("Database connections error"); mysql_select_db("$dbase") or die("Database unavailable"); $i=1; foreach($_POST[''imageFloatContainer''] as $key=>$value) { mysql_query("UPDATE main SET displayOrder=''".$i."'' WHERE id =''".$value."''"); $i++; } ?> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi there, Please make sure you follow the guidelines for identifiers as described on: http://wiki.script.aculo.us/scriptaculous/show/Sortable.serialize To see Ajax requests as they are made, use Firebug: http://www.joehewitt.com/software/firebug/ Best, Thomas Am 25.09.2006 um 03:09 schrieb webgodjj:> > Hi, I am having a problem with sortables. I can drag the images > around, but it doesn''t update my records in my database... I''m not > sure > if it''s even calling the file... here is my code: > > <div id="imageFloatContainer"> > <img src="http://fashdax.com/gallery/I/2005/01/01/thumb/3.jpg" id="3"> > <img src="http://fashdax.com/gallery/I/2005/01/01/thumb/4.jpg" id="4"> > <img src="http://fashdax.com/gallery/I/2005/01/01/thumb/5.jpg" id="5"> > </div> > <script type="text/javascript"> > function updateOrder(){ > var options = { > method : ''post'', > parameters : Sortable.serialize(''imageFloatContainer'') > }; > new Ajax.Request(''http://www.fashdax.com/gallery_update.php'', > options); > } > Sortable.create(''imageFloatContainer'', > {tag:''img'',overlap:''horizontal'',constraint: false, onUpdate : > updateOrder}); > </script> > > PHP FILE: > <? > include(config.php); > > mysql_connect("$host","$user","$pass") or die("Database connections > error"); > mysql_select_db("$dbase") or die("Database unavailable"); > > $i=1; > foreach($_POST[''imageFloatContainer''] as $key=>$value) { > mysql_query("UPDATE main SET displayOrder=''".$i."'' WHERE id > =''".$value."''"); > $i++; > } > > ?> > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Thomas, I''m unsure what you mean by this.... I believe that the identifier is the id attribute of the images right? I set those to be pulled from the database via php. Do they need the format images_1 or can the id just be 1? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
webgodjj a écrit :> Hi Thomas, > > I''m unsure what you mean by this.... I believe that the identifier is > the id attribute of the images right? I set those to be pulled from > the database via php. Do they need the format images_1 or can the id > just be 1?The ID values for sortable items need to be prefix_id, whatever the prefix. -- 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 -~----------~----~----~----~------~----~------~--~---
Ok... so I renamed the id''s of the images to me id="image_1" etc... however, still no go... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Here is the new code, which doesn''t seem to do any updating...: <div id="imageFloatContainer"> <? PHP CODE TO GRAB PHOTOS WITH THE ID BEING in the form of id="image_1" CREATING THIS LIST: <img src="http://fashdax.com/gallery/I/2005/01/01/thumb/3.jpg" id="image_3"> <img src="http://fashdax.com/gallery/I/2005/01/01/thumb/4.jpg" id="image_4"> <img src="http://fashdax.com/gallery/I/2005/01/01/thumb/5.jpg" id="image_5"> ?> </div> <script type="text/javascript"> function updateOrder(){ var options = { method : ''post'', parameters : Sortable.serialize(''imageFloatContainer'') }; new Ajax.Request(''http://www.fashdax.com/gallery_update.php'', options); } Sortable.create(''imageFloatContainer'', {tag:''img'',overlap:''horizontal'',constraint: false, onUpdate : updateOrder}); </script> --~--~---------~--~----~------------~-------~--~----~ 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 again, webgodjj a écrit :> Here is the new code, which doesn''t seem to do any updating...: > > <div id="imageFloatContainer"> > <? > PHP CODE TO GRAB PHOTOS WITH THE ID BEING in the form of id="image_1" > CREATING THIS LIST: > <img src="http://fashdax.com/gallery/I/2005/01/01/thumb/3.jpg" > id="image_3"> > <img src="http://fashdax.com/gallery/I/2005/01/01/thumb/4.jpg" > id="image_4"> > <img src="http://fashdax.com/gallery/I/2005/01/01/thumb/5.jpg" > id="image_5"> > ?> > </div>Let me rephrase... Your IDs must be of the format blahblah_actualIDValue. So here, your values will be 1, 3, 4 and 5. Sortable.serialize, based on your Sortable.create call:> Sortable.create(''imageFloatContainer'', > {tag:''img'',overlap:''horizontal'',constraint: false, onUpdate : > updateOrder});Does not have a specified param name, so it will take your element''s ID: ''imageFloatContainer'', as a param name. Sortable.serialize will then create a sequence like this (herebelow, IFC stands for the full name, for the sake of brevity in this post): IFC[]=1&IFC[]=3&IFC[]=4&IFC[]=5 (for an unmodified order, say). You know, as I do, that PHP will build an array from this, which is convenient for your code. One way to go is to have your PHP code log its request params somewhere for you to see! Better yet: use Firebug to trace XHR''s to your server side, in order to check what params are sent in. By doing that, you would already have seen, for instance, that sent values do *not* include the prefix in the IDs. ''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 -~----------~----~----~----~------~----~------~--~---
Wow... I still am having a hard time getting my head around this. So I made a demo available here: http://fashdax.com/gallery_deleteme.php I installed Firebug, and don''t see any requests being made... I also turned on all the error options on. So something might be amiss in my structure? I don''t think that the ajax event is trigering at all.... Can you think of why that would be?? NEW PAGE CODE: <? $host = "###"; $user = "###"; $pass = "###"; $dbase = "###"; mysql_connect("$host","$user","$pass") or die("Database connections error"); mysql_select_db("$dbase") or die("Database unavailable"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <title>Fashdax | Your Fashion Connection</title> <script type="text/javascript" src="http://fashdax.com/inc/script/scriptaculous/prototype.js"></script> <script type="text/javascript" src="http://fashdax.com/inc/script/scriptaculous/scriptaculous.js"></script> <link rel="stylesheet" type="text/css" href="http://fashdax.com/inc/css_source/space.css" /> </head> <body> <div id="imageFloatContainer"> <? $a = mysql_query("SELECT * FROM `main` WHERE `user` = ''webgodjj'' ORDER BY `displayOrder` ASC"); while ($b = mysql_fetch_array($a)) { $i++; echo ''<img src="http://www.fashdax.com/gallery/I/2005/01/01/thumb/''.$b[''id''].''.jpg" id="''.$b[''id''].''">''."\n"; } ?> </div> <script type="text/javascript"> function updateOrder(){ var options = { method : ''post'', parameters : Sortable.serialize(''imageFloatContainer'') }; new Ajax.Request(''http://www.fashdax.com/gallery_update.php'', options); } Sortable.create(''imageFloatContainer'', {tag:''img'',overlap:''horizontal'',constraint: false, onUpdate : updateOrder}); </script> </body> </html> --~--~---------~--~----~------------~-------~--~----~ 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 think for each of your images <img src="http://www.fashdax.com/gallery/I/2005/01/01/thumb/4.jpg" id="4"> should be <img src="http://www.fashdax.com/gallery/I/2005/01/01/thumb/4.jpg" id="image_4"> Cheers Rob webgodjj wrote:> Wow... I still am having a hard time getting my head around this. So I > made a demo available here: > > http://fashdax.com/gallery_deleteme.php >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---