php - JQuery UI sortable saving with connected lists -


i have 2 lists (1 , 2) , want update them when item moved 1 another.

html:

<ul class="sortable" id="task-list">    <li id="listitem_1">value 1 </li>    <li id="listitem_2">value 2 </li>    <li id="listitem_3">value 3 </li> </ul>  <ul class="sortable" id="task-list-two">    <li id="listitem_4">value 1 </li>    <li id="listitem_5">value 2 </li>    <li id="listitem_6">value 3 </li> </ul> 

js:

$("#task-list, #task-list-two").sortable({     handle : '.handle',    connectwith: ".sortable"     update : function () {       var order = $('#task-list').sortable('serialize');       $("#info").load("process-sortable.php?"+order);     }  }); 

but want update list (1 or 2) well. need post additional variable process.sortable.php ?

the foreach have first list (simplified):

$task = nl2br($_post['task']); $userid = $_session['userid']; $position = $_post['p']; $date = $_post['date'];  $i = "insert tasks values('','$task','$userid','0','$position','$date')"; $doi = mysql_query($i) or die(mysql_error()); 

thanks in advance!

updated foreach php:

foreach ($_get['listitem'] $position => $item) {     $list = $_get['list'];     if($list == "task-list")     {         $list = 1;     }     if($list == "task-list-two")     {         $list = 2;     }     $sql = "update `tasks` set `position` = $position , date = '$list' `id` = $item";       print($sql);     $dosql = mysql_query($sql) or die(mysql_error()); } 

you pass lists id php page like:

$("#info").load("process-sortable.php?"+order+"&list="+$(this).attr('id'));  

once on php page, can make condition list type.

you need change order variable account different lists:

var order = $(this).sortable( "serialize" ); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -