Appearance
Javascript API
With the Javascript API, you are able to set the content for an wyvern instance.
Ready
Execute a callback function when the Wyvern editor is ready
REINOS_WYVERN.ready(id, function(){
// you callback code
});
SetContent
Set the content of a Wyvern instance
REINOS_WYVERN.setContent({
id: 'id-of-the-instance',
content: 'override content',
defaultContent: 'Some default text',
});
Examples
Practical use case for channel form, setting a default value
{exp:channel:form id="wyvern" channel="wyvern" return="site/channel-form" include_assets="yes"}
<input name="title" type="text">
<input name="url_title" type="text">
<div class="wyvern-channel-form">{field:wyvern}</div>
<input type="submit" value="Submit">
{/exp:channel:form}
<script>
window.onload = function(){
var id = document.querySelector('.wyvern-channel-form textarea').dataset.id;
REINOS_WYVERN.ready(id, function(){
REINOS_WYVERN.setContent({
id: id,
content: 'override content',
defaultContent: 'Some default text',
});
});
}
</script>