拖放获取 table 行 ID
Drag and Drop get table row id
我有一个 tables 和子 tables ,这里是 Fiddle 现在当我拖放子 table 行时我得到
$('.row_position>tr').each(function() {
selectedData.push({'id':i,'key':$(this).attr("name")});
i++;
});
在 IT 部门下,我有两个子项 Backlog 和 WIP,所以当我拖放时,我除了 selectedData.push
有两个值,但我得到的不是两个值
[
{"id":1,"key":"11"},
{"id":2,"key":"10"},
{"id":3,"key":"12"},
{"id":4,"key":"13"}
]
我除外
[
{"id":1,"key":"11"},
{"id":2,"key":"10"}
]
又是console.log(JSON.stringify(selectedData));
我进不去ajaxurl.Please帮帮我
我已经将 $('.row_position>tr').each(function() 更改为 $(this).find('tr').each(function() 所以你会仅获取当前子 table
的数据
并且对于 ajax URL,您需要将完整的实际值 URL 放入函数 updateOrder
$( ".row_position" ).sortable({
delay: 150,
stop: function(th) {
// var par = th.parent();
// console.log(JSON.stringify(th));
var selectedData = new Array();
var i=1;
$(this).find('tr').each(function() {
selectedData.push({'id':i,'key':$(this).attr("name")});
i++;
});
console.log(JSON.stringify(selectedData));
updateOrder(selectedData);
}
});
我有一个 tables 和子 tables ,这里是 Fiddle 现在当我拖放子 table 行时我得到
$('.row_position>tr').each(function() {
selectedData.push({'id':i,'key':$(this).attr("name")});
i++;
});
在 IT 部门下,我有两个子项 Backlog 和 WIP,所以当我拖放时,我除了 selectedData.push
有两个值,但我得到的不是两个值
[
{"id":1,"key":"11"},
{"id":2,"key":"10"},
{"id":3,"key":"12"},
{"id":4,"key":"13"}
]
我除外
[
{"id":1,"key":"11"},
{"id":2,"key":"10"}
]
又是console.log(JSON.stringify(selectedData));
我进不去ajaxurl.Please帮帮我
我已经将 $('.row_position>tr').each(function() 更改为 $(this).find('tr').each(function() 所以你会仅获取当前子 table
的数据并且对于 ajax URL,您需要将完整的实际值 URL 放入函数 updateOrder
$( ".row_position" ).sortable({
delay: 150,
stop: function(th) {
// var par = th.parent();
// console.log(JSON.stringify(th));
var selectedData = new Array();
var i=1;
$(this).find('tr').each(function() {
selectedData.push({'id':i,'key':$(this).attr("name")});
i++;
});
console.log(JSON.stringify(selectedData));
updateOrder(selectedData);
}
});