【问题标题】:Jeditable + keytables clickeventJeditable + keytables clickevent
【发布时间】:2017-11-19 00:52:06
【问题描述】:

我为我的表使用插件 keyTables 和 jeditable。

我可以在网格中导航并通过返回激活 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 );
} );
} );

代码和插件是一样的。我应该只能通过单击来编辑带有返回事件的单元格。

有什么想法吗?

【问题讨论】:

    标签: jquery jeditable


    【解决方案1】:

    简单..

    添加

     $(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 );
                } );
    

    将使它工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-19
      • 1970-01-01
      • 2020-10-03
      • 2013-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多