I have function that creates textareas fields on the fly upon a click on a link
I want to convert these textareas into tinymce wysiwyg
here is the code
$("body").delegate("a.add_tab","click",function(e){
e.preventDefault();
var uniq = $(this).attr("uniqid");
add_tab_ui($(this),uniq);
});
function add_tab_ui(elem,uniq){
var content = "<div class='wrapTab'><label >Tab Title:<input type='text' name='tab-title-"+uniq+"' id='tab-title' value='' placeholder = 'Add Tab Title' /> </label><br/><br/>";
content+= "<label>Tab Content: <textarea name='tab-content-"+uniq+"' class='tinymce_enabled' id='tab-content' ></textarea></label><br/><br/><a href='#' class='del_tab'>Delete Tab</a><br/><br/></div>"
$(content).appendTo(elem.parent()).parent().sortable({cursor:'move'});
add_tmce();
}
function add_tmce(){
tinyMCE.init();
tinyMCE.execCommand("mceAddControl", false,'textarea#tab-content');
}
The way I did does not work
what I am really looking for is a way to automatically replace every textarea with id "tab-content" into tinymce wysiwyg and that should happen ON THE FLY
Also note that I am working inside wordpress back end and I MUST use the javascript way to do it NOT the php way wp_editor() function which is built-in wordpress
Any thoughts are appreciated :)