Javascript 什么可以防止IE8中触发按键关闭事件?

Javascript 什么可以防止IE8中触发按键关闭事件?,javascript,internet-explorer,keydown,textinput,Javascript,Internet Explorer,Keydown,Textinput,我制作了一个可编辑的实现,其行为是: dblclick on元素使其可编辑: 创建一个输入 元素内容已清空 附加到元素的输入 将keydown事件处理程序附加到输入,以在用户按Enter键时禁用编辑 带模糊事件的idem 它在decents浏览器中运行良好,但在IE8上出现故障 有两个问题: input.focus将调用模糊事件处理程序wtf?? 击键不会生成keydown处理程序截获的事件,因此当按下enter时要验证的处理程序不起作用 我检查了输入上的点击事件,它们很好 问题是,如果我在极简

我制作了一个可编辑的实现,其行为是:

dblclick on元素使其可编辑:

创建一个输入 元素内容已清空 附加到元素的输入 将keydown事件处理程序附加到输入,以在用户按Enter键时禁用编辑 带模糊事件的idem 它在decents浏览器中运行良好,但在IE8上出现故障

有两个问题:

input.focus将调用模糊事件处理程序wtf?? 击键不会生成keydown处理程序截获的事件,因此当按下enter时要验证的处理程序不起作用 我检查了输入上的点击事件,它们很好 问题是,如果我在极简主义示例中运行该示例,它仍然有效,但在我的应用程序中,它不会

什么可以防止这些按键关闭事件被触发/捕获

以下是实现:

widget.Editable = function( el, options ) {
    this.element = $(el).addClass('editable');
    this.value = this.element.text();

    var _that = this;
    this.element.dblclick( function(e) {
        _that.enableEdition();
    } );
};

widget.Editable.prototype = {
    disableEdition: function( save, e ) {
        this.value = this.input.val();
        this.input.remove();
        this.element.text( this.value ).removeClass('dragDisable');
        this.editionEnabled = false;
        this.onupdate( e, this.value, this.element );
    },
    /**
     * enables the field for edition. Its contents will be placed in an input. Then
     * a hit on "enter" key will save the field.
     * @method enableEdition
     */
    enableEdition: function() {
        if (this.editionEnabled) return;
        var _that = this;
        this.value = this.element.text();
        this.input = $( document.createElement('input') ).attr({
            type:'text',
            value:this.value
        });
        this.element
            .empty().append( this.input )
            .addClass('dragDisable'); //We must disable drag in order to not prevent selection
        this.input.keydown( function(e) {
            IScope.log('keydown editable:', e );
            switch ( e.keyCode ) {
            case 13:
                _that.disableEdition( true );
                break;
            default:
                break;
            }
        } );
        this.input.click( function() {
            console.log('input clicked');
        });

        //if ( !YAHOO.env.ua.ie ) 
        //  this.input.blur( function( e ) {
        //      IScope.log( "editable blurred", e );
        //      _that.disableEdition( true );
        //  });

        //this.input.focus();
        this.editionEnabled = true;
    }
};