【发布时间】:2016-08-08 17:03:33
【问题描述】:
我在我的页面中嵌入了 ace-widget。我添加了一个使用 getvalue() 方法读取编辑器会话值的按钮。单击按钮后编辑器消失。可能是什么原因导致错误?请在下面的链接中找到屏幕截图。
<ace-widget id="editor1" initial-focus theme="ace/theme/monokai" mode="ace/mode/json" softtabs="true" wrap="true">
This is a nice widget... and we are writing a long text here to show the effects of the `wrap` attribute.
</ace-widget>
<paper-button raised class="custom indigo" onclick="myrun()">Run</paper-button>
<paper-textarea label="autoresizing textarea input"></paper-textarea>
<script type="text/javascript">
function myrun(){
var editor = ace.edit("editor1");
var myVar = editor.getSession().getValue();
myVar= myVar.replace(/\d+/, '');
myVar = myVar.substring(0,myVar.indexOf('XXXXXXX'));
alert(myVar);
}
</script>
【问题讨论】:
标签: javascript html web polymer-1.0 ace-editor