[英]How do I detect line change event in ace editor?
我正在嘗試在ace編輯器中捕獲行更改事件。 每次用戶按下輸入,都會更改行,console.log顯示當前行號。 我試圖執行以下代碼。
editor.getSession().getRowLength().on('change', function(event) {
if (lineno ==1){
//execute abc}
else if (lineno==2){
//execute xyz}
});
我收到以下錯誤
tryit-ide.js:20 Uncaught TypeError: editor.getSession(...).getRowLength(...).on is not a function
at tryit-ide.js:20
at setUp (arch_ace-editor.js?hash=d1163619d62832acc5c961ddb94093c49630a447:78)
at callback (arch_ace-editor.js?hash=d1163619d62832acc5c961ddb94093c49630a447:98)
at arch_ace-editor.js?hash=d1163619d62832acc5c961ddb94093c49630a447:111
at XMLHttpRequest.request.onreadystatechange (arch_ace-editor.js?hash=d1163619d62832acc5c961ddb94093c49630a447:53)
謝謝。
該錯誤僅表示您正在向一個數字添加事件偵聽器。 嘗試
editor.session.on('change', function(delta) {
var lineno = delta.start.row
if (lineno ==1){
//execute abc}
else if (lineno==2){
//execute xyz}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.