Tôi đã khởi TinyMCE như vậy:Tháo gỡ hoàn toàn JQuery TinyMCE
$('#text').tinymce({
// Location of TinyMCE script, optional, already loaded in page.
script_url : '../adminContent/js/tiny_mce/tiny_mce.js',
// General options
theme : "advanced",
plugins : "table,advimage,advlink,iespell,inlinepopups,preview,contextmenu,paste,visualchars",
// Theme options
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,forecolor,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,removeformat,cleanup,code,|,preview,tablecontrols,|,hr,visualaid,|,charmap,iespell",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true
});
Đoạn mã trên hoạt động hoàn hảo. Vấn đề là khi tôi cố gắng loại bỏ tinyMCE.
đang remove của tôi là:
$('#text').tinymce().execCommand('mceRemoveControl', false, 'text');
Tôi cũng đã thử:
$('#text').remove();
và
$('#text').tinymce().remove();
Người đầu tiên dường như không làm gì cả. Cuối cùng hai cho tôi lỗi này:
Uncaught ReferenceError: t is not defined
Mặc dù TinyMCE được tải bởi các tài liệu HTML, Tôi tải kịch bản khác sử dụng:
$.getScript(viewPath + '/mod/adminContent/js/editContent.js', function(){
initEditContent(popup);
});
cửa sổ bật lên là một tham chiếu đến các popup trong đó TinyMCE được tải . Nó chỉ đơn giản là một div được tạo ra bằng cách sử dụng jquery. Nội dung của div được tải bằng cách sử dụng jquery ajax.
Các editContent.js trông như thế này:
var contentID;
function initEditContent(popup){
contentID = $('#contentID').val();
tinyMCE.execCommand("mceAddControl", true, 'text');
setTimeout(reposition, 50);
setTimeout(reposition, 150);
setTimeout(reposition, 250);
// Submit form
$('#editTextForm').ajaxForm(
{
// Before submit
beforeSubmit: function(){
//setPopupMessage(popup, '<div id="loading"><img src="../../img/loading.gif" /> Please wait...</div>');
},
// Once submit completed
success: function(responseText){
tinyMCE.execCommand("mceRemoveControl", true, 'text');
//closePopup(popup);
// Update button with new data
$('#' + contentID).html(responseText);
}
});
}
'.tinymce() remove() 'nên làm các trick.. Bạn có thể đăng một trường hợp thử nghiệm trên [jsFiddle] (http://jsfiddle.net) nơi mà vấn đề của bạn được sao chép không? – mekwall
Tôi đã chỉnh sửa câu hỏi ban đầu của mình để cung cấp thêm chi tiết cho bạn. Không thể sử dụng jsFiddle Tôi sợ vì có quá nhiều phần bên ngoài được yêu cầu. – JPardoe
gọi là tinyMCE.remove(); và nó đưa ra một lỗi: "Uncaught TypeError: Không thể đọc thuộc tính 'id' của undefined" trên dòng 11264 của tiny_mce_src.js – JPardoe