Skip to content

Examples

Destroy / Init editor

The buttons below will destroy and init the rich text editor again.

Destroy Init

HTML

<div id="eg-destroy-init" class="text-small">
          <p>The buttons below will destroy and init the rich text editor again.</p>
        </div>
        <p>
          <a id="btn-destroy" href="#" class="r-btn highlight text-small">Destroy</a>
          <a id="btn-init" href="#" class="r-btn text-small">Init</a>
        </p>

JAVASCRIPT

<script>
  $(function() {
    $('div#eg-destroy-init').editable({
      inlineMode: false
    })
  });

  // Destroy action.
  $('a#btn-destroy').on('click', function (e) {
    e.preventDefault();

    if ($('div#eg-destroy-init').data('fa.editable')) {
      $('div#eg-destroy-init').editable('destroy');
    }
  });

  // Initialize action.
  $('a#btn-init').on('click', function (e) {
    e.preventDefault();

    if (!$('div#eg-destroy-init').data('fa.editable')) {
      $('div#eg-destroy-init').editable({
        inlineMode: false
      });
    }
  });
</script>