So i have a page that submits a form using ajax and then on success reloads the data/form. When the page initially loads, tinymce loads just fine with the page. When i submit the form, the form reappears but its just a textarea and not the tinymce. I think I have to initialize the tinymce again on success but i have tried and can't seem to get it to work. My Code:
My code:
$.ajax({
type: "POST",
url: "/form.php",
data: datastring,
success: function(data) {
$("#formcontainer").html(data);
tinymce.init({
selector: ".Htmltextarea"
});
},
error: function(){
alert('error handing here');
}
});
});
I also have the tinymce.init on the parent page where the form loads via ajax. Again, when I initially load the form, all works fines, the Tinymce loads. It just when i submit the form via ajax and the success/data is returned that I get the submitted form but the tinymce is gone. How to I get tinymce after ajax form submit? Thannks.
Attempt also not working:
$.ajax({
type: "POST",
url: "/form.php",
data: datastring,
success: function(data) {
$("#formcontainer").html(data);
tinymce.EditorManager.execCommand('mceRemoveEditor', true, ".Htmltextarea");
tinymce.EditorManager.execCommand('mceAddEditor', true, ".Htmltextarea");
},
error: function(){
alert('error handing here');
}
});
});
Try this:
$.ajax({
// tinyMCE.triggerSave(); // uncomment this line if tinyMCE is giving blank response
type: "POST",
url: "/form.php",
data: datastring,
success: function(data) {
$("#formcontainer").html(data);
tinymce.EditorManager.execCommand('mceAddEditor', false, ".Htmltextarea");
},
error: function(){
alert('error handing here');
}
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.