$("#ddl").change(function () {
var strSelected = "";
$("#ddl option:selected").each(function () {
strSelected += $(this)[0].value;
});
if (strSelected.length != 0) {
var url = "/Reseller/MailPartial/?resellerId=" + strSelected;
$("#mail").empty();
$("#mail").load(url);
}
这是我用来在我的视图中加载部分的代码(部分只有1个标签和1个编辑器,应该加载tinymce)。我在我的模型中有[UIHint(“tinymce_jquery_full”),AllowHtml]和tinymce编辑器在其他视图中加载完全正常。但是当我使用局部视图时,它会以纯文本区域的形式返回。如何解决这个问题?
感谢
编辑:
我明白了,ijaz几乎是正确的;)
我需要像ijaz所说的那样重新启动,但即使我打电话给INitTinyMCE,就像ijaz说它不会有重要因为该元素尚未加载到html而且我不知道为什么。解决方法是在元素加载到页面后调用initTinyMce。
我试过用 $(“#mail”)。load(url,InitTinyMCE()); 但它不起作用。
在元素加载后如何调用InitTinyMCE()的任何想法?它现在正在工作,但它依靠按下另一个按钮来触发InitTinyMCE()
再次编辑 我将代码更改为纯粹的ajax,而不是更多.load()
抱歉这么乱:)答案 0 :(得分:1)
在上面的代码中,似乎没有正确应用[UIHint]。所以让事情变得有效,请将TinyMCE初始化为manualy,我的意思是将代码更改为,
$("#ddl").change(function () {
var strSelected = "";
$("#ddl option:selected").each(function () {
strSelected += $(this)[0].value;
});
if (strSelected.length != 0) {
var url = "/Reseller/MailPartial/?resellerId=" + strSelected;
$("#mail").empty();
$("#mail").load(url);
**Re-Init TinyMCE**
InitTinyMCE();
}
function InitTinyMCE()
{
$('#@ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)').tinymce({
// Location of TinyMCE script
script_url: '@Url.Content("~/Scripts/tinymce/tiny_mce.js")',
theme: "advanced",
height: "170",
width: "240",
verify_html : false,
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,wordcount,advlist,autosave",
// Theme options
theme_advanced_buttons1: "undo, redo,pasteword,|, bold, italic, underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,image, emotions" ,
theme_advanced_buttons2: "charmap, bullist, numlist,|,formatselect,fontselect,fontsizeselectcode, |,tiny_mce_wiris_formulaEditor, fullscreen",
theme_advanced_buttons3: "",
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 : "@Url.Content("~/Scripts/tinymce/css/content.css")",
convert_urls : false,
// 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"
});
}