This example shows how to run multiple editors on a page and how to get their application.
<!-- buttons -->
<button onclick="getAllEditors(event)">getAllEditors</button>
<button onclick="getSecondEditor(event)">getSecondEditor</button>
<!-- elements -->
<textarea id="entry-1" class="entry">...</textarea>
<textarea id="entry-2" class="entry">...</textarea>
<!-- call -->
<script>
let apps = Redactor('.entry');
function getAllEditors(e) {
e.preventDefault();
// array of editors
console.log('array of editors', apps);
}
function getSecondEditor(e) {
e.preventDefault();
// get by id
let secondEditor = Redactor.dom('#entry-2').dataget('redactor')
// get the second editor
console.log('get from array', apps[1]);
console.log('get by id', secondEditor);
console.log('get html of the second editor', secondEditor.editor.getContent());
}
</script>