0

コンテキスト– jQuery ウィジェット ファクトリ。要素をレンダリングし、それらをプライベート変数に格納します。

_renderInputHolder: function () {

    var self = this;

    this._inputHolder = $(document.createElement('div'))
        .on('focusout', function (e) {
        self._hideInputHolder.apply(self, [e]);
    });

},

_renderTextInput: function () {

    var self = this;

    this._textInput = $(document.createElement('input'))
        .keypress(function (e) {
        if (e.which === 13) {
            self._hideInputHolder();
        }
    });
},

_hideInputHolder: function () {

    this._inputHolder = this._inputHolder.detach();

},

問題– 2 つの別個の要素に、コンテナー要素を分離しようとする独立したイベントがあります。テキスト入力で Enter キーを押すと、inputContainer が切り離されますが、これにより、inputContainer で「focusout」イベントがトリガーされ、

Uncaught Error: NotFoundError: DOM Exception 8 

再び切り離そうとします。

エラーなしでinputContainerの削除を確実にする最良の方法は何ですか?または.detach()を呼び出すことができることを確認しますか?

4

2 に答える 2