【问题标题】:With the ACE Editor, how can I unbind an event?使用 ACE 编辑器,如何取消绑定事件?
【发布时间】:2011-09-03 16:28:46
【问题描述】:

https://github.com/ajaxorg/ace/wiki/Embedding---API

editor.session.on('change', callback);

是您如何将事件绑定到“更改”。但是如何解绑呢?

【问题讨论】:

    标签: javascript dom-events ace-editor


    【解决方案1】:

    使用removeListener 删除特定回调。

    editor.session.removeListener('change', callback);
    

    或更短的版本

    editor.session.off('change', callback);
    

    使用removeAllListeners 删除所有回调。

    editor.session.removeAllListeners('change');
    

    【讨论】:

    • 可能值得注意的是editor.session.off('change')(没有回调,将不起作用。
    • 我遇到了editor.session.removeAllListeners('change'); 的问题。编辑器停止呈现更改,就好像正在使用内部更改事件来刷新内容一样。目标版本运行良好。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多