繁体   English   中英

如何在.on('input')事件(ace.js)中忽略setValue

[英]How to ignore setValue in the .on('input') event (ace.js)

editor.on('input', function(e, target) {
    console.log(true);
});

editor.getSession().setValue('value'); // How not to handle it in the input event?

怎么做?

超时后会触发输入事件,如果您快速进行多项更改,则只会触发一次。 如果您使用更改事件,则可以

var ignore, changed
editor.on('input', function() { // async and batched
    if (changed) console.log(e);
    changed = false
});
editor.on('change', function() { // sync for each change
    if (!ignore) changed = true
});
ignore = true
editor.getSession().setValue('value');
ignore = false

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM