我正在使用以下代码启用jeditable的实时编辑:
<script type="text/javascript">
$(document).ready(function(){
var aDataSet = [
["klad1111.com","<img src='world/se.png' />","-","0","0","0%","0"],
["klad2222.com","<img src='world/dk.png' />","2012-12-05","1","3","300%","15"],
["klad33333.com","<img src='world/dk.png' />","-","0","0","0%","0"],
["klad6666.info","<img src='world/dk.png' />","-","0","0","0%","0"],
["klad44444.info","<img src='world/dk.png' />","-","0","0","0%","0"],
["klad5555.com","<img src='world/se.png' />","-","0","0","0%","0"],
];
$('#dynamic').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"></table>' );
$('#example').dataTable( {
"aaData": aDataSet,
"aoColumns": [
{ "sTitle": "Namn" },
{ "sTitle": "Land" },
{ "sTitle": "Uppdaterad" },
{ "sTitle": "Neutrala Posts", "sClass": "center" },
{ "sTitle": "Post / Client", "sClass": "center" },
{ "sTitle": "Ratio", "sClass": "center" },
{ "sTitle": "Total Posts", "sClass": "center" }
]
} );
/* Init DataTables */
var oTable = $('#example').dataTable();
/* Apply the jEditable handlers to the table */
$('td', oTable.fnGetNodes()).editable( 'editable_ajax.php', {
"callback": function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1] );
},
"submitdata": function ( value, settings ) {
return {
"row_id": this.parentNode.getAttribute('id'),
"column": oTable.fnGetPosition( this )[2]
};
},
"height": "14px"
} );
});
</script>
实时编辑一些作品,当我点击一个单元格时,我起了一个输入框。但保存部分不起作用..我不确定如何相应地更新我的数据库..
有什么想法吗?