two instances of tinymce mvc c#

北战南征 提交于 2019-12-13 06:27:41

问题


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:


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



来源:https://stackoverflow.com/questions/20146044/two-instances-of-tinymce-mvc-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!