【问题标题】:Where to set Ace editor blockScrolling?在哪里设置 Ace 编辑器块滚动?
【发布时间】:2015-03-09 06:46:56
【问题描述】:

当我使用ace(与jquery-ace)将文本区域更改为ace-editor 时,它会在控制台上显示此警告:

Automatically scrolling cursor into view after selection change 
this will be disabled in the next version 
set editor.$blockScrolling = Infinity to disable this message

在哪里设置 editor.$blockScrolling 变量以删除这些警告?

var aces = el.find('textarea.code.json');
var aceInit = function() {
 //window.ace.$blockScrolling = Infinity; // no effect
 //$.ace.$blockScrolling = Infinity; // no effect
 //window.jQueryAce.AceDecorator.$blockScrolling = Infinity; // no effect
 //window.jQueryAce.BaseEditor.$blockScrolling = Infinity; // no effect
 //window.jQueryAce.TextAreaEditor.$blockScrolling = Infinity; // no effect
 aces.ace({theme: 'eclipse', lang: 'json'}).each(function (idx, editor) {
  var el = $(editor);
  var editor = el.data('ace').editor;
  //editor.$blockScrolling = Infinity; // no effect
  var ace = editor.ace;
  //ace.$blockScrolling = Infinity; // no effect, even this the correct one
  ace.setReadOnly(el.prop('disabled'));
  ace.setOption("maxLines", 10);
  ace.setOption("minLines", 2);
 });
}; // this function called when ace.js, mode-json.js and jquery-ace.js loaded

【问题讨论】:

  • 带有// no effect, even this the correct one 的那个是正确的。也许稍后会取消该属性?你能创建一个演示这个问题的演示吗?
  • 啊等等,它现在可以工作了,也许我忘了重新加载 javascript..

标签: javascript jquery ace-editor


【解决方案1】:

正确的应该是:

var el = $(the_element);
var editor = el.data('ace').editor;
editor.$blockScrolling = Infinity;

【讨论】:

    猜你喜欢
    • 2017-06-07
    • 2019-11-30
    • 1970-01-01
    • 2011-10-26
    • 2014-12-13
    • 2015-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多