title: How do I save / restore or maintain cursor position in a NicEdit RTE?
body: <p>I'm trying to save the cursor position in my NicEdit rich text editor so that after posting to the server I can restore the exact location the user was working.</p>
  
  <p>Currently I am trying to accomplish this all on the client side so that I can be sure it works before attempting to save the range variables during a post.</p>
  
  <pre><code>&lt;textarea id="editor" style="height:500px;width:500px;"&gt;&lt;/textarea&gt;    
  &lt;input type="button" value="Save Postion" onclick="SavePosition();return false;" /&gt;
  &lt;input type="button" value="Restore Postion" onclick="RestorePosition();return false;" /&gt;
  
  &lt;script type="text/javascript"&gt;
      var editor;
      $(function () {
          editor = new nicEditor({ fullPanel: false });
          editor.addInstance('editor');
      });
  
      var range = null;
      var sel = null;
      function RestorePosition() {
          editor.nicInstances[0].selRng(range, sel);
          $('.nicEdit-main').focus();
      }
      function SavePosition() {
          range = editor.nicInstances[0].getRng();
          sel = editor.nicInstances[0].getSel();
          $('.nicEdit-main').focus(); 
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>If a user highlights a word, clicks Save, clicks somewhere else then clicks Restore the selection will be restored.<br>
  However if the cursor is just sitting there blinking when Save is pressed, pressing Restore will move the cursor to the start.</p>