簡體   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