【发布时间】:2014-07-05 08:39:52
【问题描述】:
我有以下 jQuery 代码:
var isOk = true;
$('#edit').click(function () {
if (isOk) {
$('table tbody').sortable({
axis: 'y',
update: function (event, ui) {
var data = $(this).sortable('serialize');
$.ajax({
data: data,
type: 'POST',
url: 'updatePagesOrder.php',
success: function (msg) { //re-number the rows from 1 to n
$('table > tbody tr').each(function (i) {
$(this).attr('id', 'item-' + (i + 1)); // use $(this) as a reference to current tr object
});
},
error: function () {
alert("An error occurred");
}
});
}
}, "enable");
}
else {
$("table tbody").unbind();
$('table a').unbind();
}
isOk = !isOk;
在上面的代码中,#edit 是一个按钮,第一次点击它会导致表格行可排序,第二次点击它会禁用可排序选项。
我希望在第三次单击时,行将再次可排序。 上面的代码我试过了,还是不行。
为什么?我该如何解决?谢谢!
【问题讨论】:
-
不知道为什么这被否决了...好问题
标签: javascript jquery jquery-ui jquery-ui-sortable sortables