#open_dialog
上的click事件会触发jQuery UI对话框,并向/ajax/request/url/
发送ajax请求
我想在从ajax请求发回的being的textarea上启动Tinymce。
使用以下代码,我得到日志消息“ ajax done!”。每次我单击#open_dialog
(并且ajax请求已完成),但Tinymce仅在第一次打开对话框时才加载。怎么来的?以及每次加载对话框时如何启动tinymce?
$('#open_dialog').click(function() {
$.when($.ajax("/ajax/request/url/")).done(function() {
console.log("ajax done!");
tinymce.init({selector:"textarea",
toolbar: "undo redo cut copy paste | bold italic underline | bullist numlist | table | styleselect | removeformat ",
plugins: "paste, table",
paste_word_valid_elements: "b,strong,i,em,h1,h2,table,tr,td,th",
menubar: false,
statusbar: true,
resize: "both"
});
});
});
最佳答案
最后通过删除旧的DOM和旧的编辑器解决了它。下面的ee_body
是文本区域的DOM ID。
$(document).ready(function() {
tinymce.init({
mode:"none",
toolbar: "undo redo cut copy paste | bold italic underline | bullist numlist | table | styleselect | removeformat ",
plugins: "paste, table",
paste_word_valid_elements: "b,strong,i,em,h1,h2,table,tr,td,th",
menubar: false,
statusbar: true,
resize: "both"
});
});
$('#open_dialog').click(function(){
//Remove old editors and DOM-elements
tinymce.EditorManager.execCommand("mceRemoveEditor", false, "ee_body");
$('#ee_body').remove();
// When ajax request to new email is done, load Tinymce
$.when($.ajax("/ajax/request/url/")).done(function() {
tinyMCE.execCommand("mceAddEditor", true, "ee_body");
});
});
关于javascript - 在jQuery UI对话框上启动TinyMce,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23787620/