我正在尝试重新加载tinymce保存的数据。当我这样做时,所有 html 标签都可以在控件内查看。
如何将 html 加载回控件中,就像之前保存的一样(没有 标签可见)?
这是我的初始化:
$('textarea.tinymce').tinymce({
// Location of TinyMCE script
script_url : '/Scripts/tinymce/tiny_mce.js',
encoding: "xml",
// 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,|,forecolor,backcolor",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,undo,redo,|,image,",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,ltr,rtl,|,fullscreen",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : false,
// Example content CSS (should be your site CSS)
//content_css : "/Content/content.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url: "/Scripts/tinymce/lists/template_list.js",
external_link_list_url: "/Scripts/tinymce/lists/link_list.js",
external_image_list_url: "/Scripts/tinymce/lists/image_list.js",
media_external_list_url: "/Scripts/tinymce/lists/media_list.js"
});//end tinymce
和我的文本区域:
<%: Html.TextArea("Blog", Model.Blog, new { @class = "tinymce", rows = "25", cols = "40" })%>
感谢您的宝贵时间。 比利
最佳答案
使用 MVC 2 -
对我来说,这个问题的解决方案是存储使用 HttpUtility.HtmlDecode 解码的数据。
然后,当将其拉回并分配给模型的显示(字符串)属性时,我使用 HttpUtility.HtmlEncode 对字符串进行编码。
最后,在 View 页面上,我再次使用 HttpUtility.HtmlDecode 解码了相同的属性以进行显示。
希望这可以帮助其他遇到类似问题的人。
关于Tinymce - 使用 html 标签重新加载数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14244024/