0
votes

TinyMCE View Template

<script src="@Url.Content("~/Scripts/tinymce/tiny_mce.js")" type="text/javascript"></script>

<script type="text/javascript">
    (function () {
        tinyMCE.init({
            mode: "textareas",
            //elements: "engRichMCE,araRichMCE",
            elements: "@ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)",
            theme: "simple",
            height: "300",
            width: "400",
            verify_html: false,
            theme_simple_resizing: true,
            content_css: "@Url.Content("~/Content/Site.css")",
            convert_urls: false
        })
    })();
</script>

@Html.TextArea(string.Empty, /* Name suffix */
    ViewData.TemplateInfo.FormattedModelValue /* Initial value */
)

Model

 [UIHint("tinymce_full_compressed"), AllowHtml]
 public string eng_html { get; set; }

 [UIHint("tinymce_full_compressed"), AllowHtml]
 public string ara_html { get; set; }

View

@Html.EditorFor(model => model.eng_html, new { id = "engRichMCE" })
@Html.ValidationMessageFor(model => model.eng_html)

@Html.EditorFor(model => model.ara_html, new { id = "araRichMCE" })
@Html.ValidationMessageFor(model => model.ara_html)

The Problem is only one instance of tinyMCE is loading in my view, i need both fields to get tinyMCE editor, any advice ?

Update What i've done so far, looking at tinyMCE documentations, http://www.tinymce.com/wiki.php/Configuration3x:mode mode value can be exact, textareas or specific_textareas. If set mode="textarea" in the init function, all textareas are converted to tinMCE...which is not what i need.

Also duplicating the partial view that holds the tinyMCE didn't work.

using mode="exact" and elements="araRichMCE,engRichMCE" in tinyMCE init function and adding IDs in my view did not work either ?

1
Load this site in Chrome or Firefox and check the Console; there are probably some JavaScript errors. - Mike Perrenoud
JS Error: 'TypeError: q is not a constructor' - Hakim
And if you work through the JavaScript for tinymce you'll find some context for that error I'm guessing. For me personally to help you're going to have to get me a lot more context about that error. Some others here may know the JS for that control better. - Mike Perrenoud

1 Answers

1
votes

SOLVED

Upadated Package TinyMCE downloaded latest 4.0.11

in my model deleted this

[UIHint("tinymce_simple"), AllowHtml]

and kept

[DataType(DataType.MultilineText)]

in my edit view page edit.view

<script src="@Url.Content("~/Scripts/tinymce/tinymce.min.js")" type="text/javascript"></script>

    <script type="text/javascript">
        (function () {
            tinyMCE.init({
                selector: "textarea#eng_html,textarea#ara_html",
                content_css: "@Url.Content("~/Content/Site.css")",
            })
        })();
    </script>

in the view my two html containg textareas will be selected by tinyMCE

Thank you all