I created an list for sort few cities and using jQuery-ui plugin for draggable sorting. The problem is that the sorting is working, but when I try to serialize the values it does nothing and when I check the Chrome dev tools I see the following error:
ERROR: Uncaught Error: cannot call methods on sortable prior to initialization; attempted to call method 'serialize' jquery-1.8.3.min.js:487
v.extend.error jquery-1.8.3.min.js:487 (anonymous function) jquery-ui-1.10.1.custom.min.js:6 v.extend.each jquery-1.8.3.min.js:536 v.fn.v.each jquery-1.8.3.min.js:416 e.fn.(anonymous function) jquery-ui-1.10.1.custom.min.js:6 (anonymous function) dragCity.php:365 v.event.dispatch jquery-1.8.3.min.js:1141 o.handle.u jquery-1.8.3.min.js:1061
PHP/HTML CODE:
<div class="row-fluid" id="sortable_portlets">
<div class="span4 column sortable">
<!-- BEGIN Portlet PORTLET-->
<?php
$lisres = mysql_query("SELECT `cityid`, `name`, `cityodr` FROM `tbl_city`");
$count = 1;
while ($resrow = mysql_fetch_array($lisres)) {
$ctynme = $resrow['name'];
$ctyid = $resrow['cityid'];
if ($count < 10) {
$sp = "0";
} else {
$sp = "";
}
?>
<label class="portlet" id="drag_<?php echo $ctyid; ?>">
<?php
echo $sp;
echo $count . " " . $ctynme;
?>
</label>
<?php
$count = $count + 1;
}
?>
</div>
</div>
<div id="rush">
</div>
Script code:
$("label").click(function() {
var sorted = $("label").sortable("serialize", {key: "drag"});
$.post("scripts/check.php", {dash: sorted}, function(data) {
var res = data;
$("#rush").html(res);
});
});