gpt4 book ai didi

jquery - DataTables & JQuery Jeditable,如何传入行数据?

转载 作者:行者123 更新时间:2023-12-01 03:50:19 26 4
gpt4 key购买 nike

我正在使用 Jeditable,

http://www.appelsiini.net/projects/jeditable

和数据表,

http://datatables.net/download/

尝试制作一个实时可编辑表格,但每当我编辑时,它都不会发布我从中获取的行 ID,因此我想在编辑列时尝试提取正确的 ID。然而,无论我尝试什么,似乎都没有得到任何结果。有什么想法吗?

代码:

 $(document).ready(function() {

var oTable = $('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "scripts/getData.php",
"fnDrawCallback": function () {
$('#example tbody td').editable( 'examples_support/editable_ajax.php', {
"event" : 'dblclick',
"tooltip" : 'Click to edit.',
"submitdata" : {id: $(this).parent().index()},
"callback": function( sValue, y ) {
console.log(sValue);
console.log($(this).parent().index());
console.log($(this).parent().find('td:eq(3)').html());
/* Redraw the table from the new data on the server */
oTable.fnDraw();
},
"height": "14px"
} );
}
} );
} );

在此特定示例中,submitdata 返回 1,而回调中的 console.log 返回正确的信息。

最佳答案

尝试将 submitdata 对象包装在函数中,以将 this 保持在范围内...

    ...
"submitdata" : function() {return {id: $(this).parent().index()}},
...

它对我有用,希望有帮助。

干杯。

关于jquery - DataTables & JQuery Jeditable,如何传入行数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9386946/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com