![]() |
Save Jquery sortable state to DB - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Save Jquery sortable state to DB (/showthread.php?tid=36524) |
Save Jquery sortable state to DB - El Forum - 12-04-2010 [eluser]Ludovic-r[/eluser] Hi everyone, I've made a sortable list with the Jquery UI sortable (and it works well) but I need to save the current state of list in my DB. Example : I drag and drop the item1 under the item3 and I need to click on a button called "Save rank state" to save the rank in my DB. Maybe I need to call a function in a controller to store the new rank in the DB, but how? Ajax maybe? In my DB I have a field called "Rank" filled with numbers. That's what I need to update How can I do that please? Any ideas? I'm stuck on this ![]() Thanks! Save Jquery sortable state to DB - El Forum - 12-04-2010 [eluser]Eric Barnes[/eluser] I do it through ajax and here is an example controller: Code: /** Example JS: Code: $(".list_wrap").sortable({ Save Jquery sortable state to DB - El Forum - 12-05-2010 [eluser]Ludovic-r[/eluser] Many thanks for your answer, it helps a lot! But now what can I do to make a button like "Save order" and give the list order to my controller? Save Jquery sortable state to DB - El Forum - 12-05-2010 [eluser]Ludovic-r[/eluser] Oh sorry, I didn't mind that it save the list automaticly (my fault) Save Jquery sortable state to DB - El Forum - 12-05-2010 [eluser]Ludovic-r[/eluser] Ok now I can't access to my $.post data from my Controller. I have this : var order = $(this).sortable("serialize"); $.post("http://localhost:8888/codeigniter/index.php/admin/order", order); And in my controller this : function order() { $order = $this->input->post('list_item'); echo $order; } I echo it just to see if it works, I know it's not its place, but unfortunately it doesn't work ![]() Save Jquery sortable state to DB - El Forum - 12-05-2010 [eluser]Eric Barnes[/eluser] Your post var is probably not list_item. The best method is to use firebug and you can see exactly what is posted. Save Jquery sortable state to DB - El Forum - 12-06-2010 [eluser]Zehee[/eluser] Code: jQuery(function($){ I referenced basecamp(a product powered by 37signals) Save Jquery sortable state to DB - El Forum - 12-06-2010 [eluser]Ludovic-r[/eluser] Ok, will try that, but if I need to call the sorted order in my Controller should I just type $this->input->post('my_var') ? I really need to communicate with my controller to store the list in my DB. Thanks for your answer! |