Create editor instances by replacing <textarea>
or <div>
elements with textboxio.replace()
. The initial content of the editor is set to the content/value of the replaced element.
When Textbox.io replaces a <textarea>
element within a <form>
, it will update the original <textarea>
element when the form is submitted, supplying updated content as part of the <form>
POST.
When Textbox.io replaces <div>
elements, content must be requested from Textbox.io using a JavaScript API, see: Setting and Getting Content.
Example
<div id="replaceMe">Content</div> ... // Create a Textbox.io editor by searching for a DOM element with id 'replaceMe' var simpleEditor = textboxio.replace( '#replaceMe' );
<div id="replaceMe">Content</div> ... // Create a Textbox.io editor by replacing a specific DOM element var div = document.getElementById('replaceMe'); var simpleEditor = textboxio.replace( div );
Parameters
or
| String or Element | Specify a CSS3 selector representing the or The |
configuration | Object (optional) | An optional group of key-value pairs that specify options/settings for the Textbox.io instances you are invoking. |
Note about selectors
If the selector matches multiple elements, only the first is replaced as per the rules for querySelector.
If it does not match any elements, a JavaScript error will be thrown. If the number of elements that will match is not known, use replaceAll
which does not have this restriction.
Returns
textboxio.editor | Object | A single instance of the Textbox.io editor. |