1

我需要编辑 dataTables jQuery 代码,所以当我单击可编辑单元格时,它将选择单元格中的整个文本。我知道它通常使用 onclick="this.select()" 完成,但 jQuery 代码对我来说很难阅读......到目前为止我的代码(至少我理解这是我需要编辑的代码):

"fnDrawCallback": function () {
        $('#table_dzs tbody tr td:nth-child(7)').editable( './files/save_dzs.php?stavba=<?echo $stavba;?>', {
            "callback": function( sValue, y ) {
                var aPos = oTable.fnGetPosition( this );
                oTable.fnUpdate( sValue, aPos[0], aPos[2] );

            },
            "submitdata": function ( value, settings ) {
                return { "id": oTable.fnGetData( this.parentNode )[0], // get the value of first row/column. In my case it is the "id" in database
                "value": oTable.fnGetPosition( this )[7] // Column number
                };

            },
            "height": "14px"
        });
    }
4

1 回答 1

1

只需在数据表初始化后添加这一行:

$.fn.editable.defaults.select = true

它是用于自定义可编辑插件的公共词典。

于 2012-12-10T10:46:43.353 回答