Reputation: 9
I'm creating a repeatable meta box using this code below. how can i add a wysiwyg editor in this textarea field . any help is very much appreciated
How to create meta box using clone ajax and jquery in wordpress
Thanks
Upvotes: 0
Views: 4442
Reputation: 13620
It is an old question but maybe someone else might need it, so here is how you do it:
<textarea id="tag-description"></textarea>
First let the document load, then check if tinyMCE present and initialize the editor.
jQuery(document).ready(function() {
if ( typeof( tinyMCE ) == "object") {
tinyMCE.init({
selector: '#tag-description'
});
}
});
Upvotes: 3
Reputation: 353
Perhaps you're using a more recent version of tinyMCE. Change
tinyMCE.execCommand("mceAddControl", false, "blurb");
with
tinyMCE.execCommand("mceAddEditor", false, "blurb");
Upvotes: 0
Reputation: 604
Add the class 'theEditor' to your textarea.
<textarea class=”theEditor” name=’blurb’ id=’blurb’></textarea>
Edit:
You can also add editor with js
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#blurb").addClass("mceEditor");
if ( typeof( tinyMCE ) == "object" &&
typeof( tinyMCE.execCommand ) == "function" ) {
tinyMCE.execCommand("mceAddControl", false, "blurb");
}
});
</script>
<textarea class="" name='blurb' id='blurb'></textarea>
Upvotes: 0