我在我的表中使用了插件keyTables和jeditable。
我可以在网格中导航并激活带有return的jeditable。但是,如果一次激活一个单元格,我只需在单元格上单击一下就可以启用jeditable。
出了点问题。
http://datatables.net/release-datatables/extras/KeyTable/editing.html
这是演示,运行良好。
我的小提琴:http://jsfiddle.net/jGC4J/
这是演示代码和我使用的代码:
$(document).ready( function () {
var keys = new KeyTable( {
"table": document.getElementById('example')
} );
/* Apply a return key event to each cell in the table */
keys.event.action( null, null, function (nCell) {
/* Block KeyTable from performing any events while jEditable is in edit mode */
keys.block = true;
/* Initialise the Editable instance for this table */
$(nCell).editable( function (sVal) {
/* Submit function (local only) - unblock KeyTable */
keys.block = false;
return sVal;
}, {
"onblur": 'submit',
"onreset": function(){
/* Unblock KeyTable, but only after this 'esc' key event has finished. Otherwise
* it will 'esc' KeyTable as well
*/
setTimeout( function () {keys.block = false;}, 0);
}
} );
/* Dispatch click event to go into edit mode - Saf 4 needs a timeout... */
setTimeout( function () { $(nCell).click(); }, 0 );
} );
} );代码和插件是一样的。我应该只能编辑一个带有返回事件的单元格,而不只是一次单击。
有什么想法吗?
发布于 2012-11-28 03:51:23
简单..。
添加
$(nCell).editable('destroy');至
/* Apply a return key event to each cell in the table */
keys.event.action( null, null, function (nCell) {
/* Block KeyTable from performing any events while jEditable is in edit mode */
keys.block = true;
/* Initialise the Editable instance for this table */
$(nCell).editable( function (sVal) {
/* Submit function (local only) - unblock KeyTable */
keys.block = false;
// INSERT HERE //
return sVal;
}, {
"onblur": 'submit',
"onreset": function(){
/* Unblock KeyTable, but only after this 'esc' key event has finished. Otherwise
* it will 'esc' KeyTable as well
*/
setTimeout( function () {keys.block = false;}, 0);
}
} );
/* Dispatch click event to go into edit mode - Saf 4 needs a timeout... */
setTimeout( function () { $(nCell).click(); }, 0 );
} );会让它工作起来。
https://stackoverflow.com/questions/13583410
复制相似问题