0
我使用插件keyTables和jeditable爲我的表。Jeditable + keytables clickevent
我可以在網格中導航並用返回激活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);
});
});
的代碼和插件是相同的。我應該只能通過返回事件來編輯單元格,而不僅僅是單擊一下。
任何想法?