2012-03-05 56 views
2

好吧,所以我有一個完整的ajax系統每個頁面加載處理,雖然ajax它的很多凌亂的代碼在這一刻,所以我不會告訴你。TinyMCE jQuery ajax從保存後不顯示

我遇到的問題是,當我到我的內容加載TinyMCE它完美的工作,一次,然後一旦表單提交它使用TinyMCE元素remove()然後一旦它完成它從內容服務器,然後有一個TinyMCE textarea和它加載奇怪的東西是內容不顯示,但如果我點擊HTML按鈕的內容是在TinyMCE textarea內。

我會盡量表現出更好的說明了一下使用盡可能少的代碼爲更多鈔票

所以這個每次conent從服務器

$(".addonContent form textarea.tinyMCE").tinymce({ 
     // Location of TinyMCE script 
     script_url : '/script/tiny_mce/tiny_mce.js', 

     // General options 
     theme : "advanced", 
     plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template", 

     // Theme options 
     theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", 
     theme_advanced_buttons2 : "cut,copy,paste,pasteword,|,bullist,numlist,|,blockquote,|,undo,redo,|,link,unlink,anchor,image,code,", 
     theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,charmap,emotions,media,|,ltr,rtl,|,fullscreen", 
     theme_advanced_buttons4 : "", 
     theme_advanced_toolbar_location : "top", 
     theme_advanced_toolbar_align : "left", 
     theme_advanced_statusbar_location : "bottom", 
     theme_advanced_resizing : true, 

     // Example content CSS (should be your site CSS) 
     content_css : "/style/style_content.css", 

     // Drop lists for link/image/media/template dialogs 
     template_external_list_url : "lists/template_list.js", 
     external_link_list_url : "lists/link_list.js", 
     external_image_list_url : "lists/image_list.js", 
     media_external_list_url : "lists/media_list.js", 

     // Replace values for the template plugin 
     template_replace_values : { 
       username : "Some User", 
       staffid : "991234" 
     } 
    }); 

重新加載時間是TinyMCE的呼叫,這個完美的作品第一次

現在我給ajaxForm代碼的運行,並將其提交數據到服務器之前調用

$(".addonContent form textarea.tinyMCE").tinymce().remove() 

但隨後當內容回來,微小的MCE負荷不會顯示在編輯器中的內容,但如果我點擊HTML按鈕,內容顯示

編輯 這似乎與TinyMCE的一個bug和谷歌瀏覽器作爲下面的代碼與IE8 +的作品,並與Firefox的作​​品,我現在嘗試CKeditor。

+0

+1好問題描述 – Thariama 2012-03-06 09:39:08

回答

0

您需要先關閉一個tinymce editro實例,然後再加載第二個具有相同ID的實例。 在此處使用mceRemoveControl execCommand。

+0

不好意思,它不是對我的工作做同樣的事情 – 2012-03-05 16:26:47

+0

你仍然稱這個:$(「。addonContent form textarea.tinyMCE」)。tinymce()。remove()?? – Thariama 2012-03-05 16:27:51

+0

不,我不只是調用,'$(「。addonContent form textarea.tinyMCE」)。tinymce()。execCommand('mceRemoveControl');' – 2012-03-05 16:29:39