samedi 16 avril 2016

Ace Code editor disappears onclick

I have embedded ace-widget in my page.I have added a button which reads the editor session value using getvalue() method. The editor disappears after I click the button.What could be the cause of error? Please find screenshot in the link below.

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

Screenshot




Aucun commentaire:

Enregistrer un commentaire