我正在使用 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/