Hakim
Hakim

Reputation: 1314

two instances of tinymce mvc c#

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 ?

Upvotes: 0

Views: 2285

Answers (1)

Hakim
Hakim

Reputation: 1314

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

Upvotes: 1

Related Questions