Question

$("#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);
        }

this is code I use to load partial in my View (partial is only 1 label and 1 editorfor,the one that should load tinymce). I have [UIHint("tinymce_jquery_full"), AllowHtml] in my model and tinymce editor loads perfectly normal in other views. But when I use partial views it comes back as plain text area. How to fix this?

thanks

EDIT:

I figured it out,ijaz was almost correct ;)

I needed to reinit tinymce like ijaz said but even when I called INitTinyMCE like ijaz said it wouldn't have mattered because the element hasn't loaded yet to html and I have no idea why. Solution was to call initTinyMce after the element has loaded to the page.

I tried to use $("#mail").load(url, InitTinyMCE()); but it didn't work.

Any ideas how to call InitTinyMCE() after the element has loaded? It's working now but it's relying on pressing another button to trigger InitTinyMCE()

EDIT again I changed code to pure ajax,no more .load()

sorry for being so messy :)

Was it helpful?

Solution

In the above code,it seems that [UIHint] is not applied properly. so get things work, kindly initialize the TinyMCE manualy, i mean change you code as ,

 $("#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"

        });
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top