Reputation: 855
Currently I use MVC model and EditorFor field with Accordion objects.
<div id="accordionSub0">
@{
int count = 0;
foreach(var item in @Model.ResolutionsList)
{
string textBoxID = "RichTextBox" + count;
string accordionSub = "accordionSub" + count;
var result = @Model.ResolutionsList[count].Resolutions;
<h3><a href="#">Step @count</a></h3>
<div id="@textBoxID" class="editor-field">
@Html.EditorFor(model => model.ResolutionsList[count].Resolutions,
new
{
style = "width:" + 100 + "%; height:" + 5 + "em;"
})
</div>
count++;
}
}
</div>
Model:
public partial class InformationDataModel
{
public int RID { get; set; }
public string Title { get; set; }
public string InfoType { get; set; }
[UIHint("tinymce_jquery_full"), AllowHtml]
public string Symptoms { get; set; }
[UIHint("tinymce_jquery_full"), AllowHtml]
public string Cause { get; set; }
[UIHint("tinymce_jquery_full"), AllowHtml]
public string Resolution { get; set; }
[UIHint("tinymce_jquery_full"), AllowHtml]
public string Resolution2 { get; set; }
[UIHint("tinymce_jquery_full"), AllowHtml]
public string References { get; set; }
public List<InformationResolutionsDataModel> ResolutionsList { get; set; }
public string IssuedDate { get; set; }
public string UserName { get; set; }
public string RelevantUsers { get; set; }
public string TagNames { get; set; }
}
public partial class InformationResolutionsDataModel
{
public int RID { get; set; }
public int ResolutionID { get; set; }
public bool IsDeleted { get; set; }
[UIHint("tinymce_jquery_full"), AllowHtml]
public string Resolutions { get; set; }
public string IssuedDate { get; set; }
public string UserName { get; set; }
}
The problem is @Html.EditorFor(model => model.ResolutionsList[count].Resolutions
,
They bring value into textarea, but they do not show with TinyMCE.
So, I check view source in website that loaded.
They automatically generate inside.
$('#ResolutionsList[0].Resolutions').tinymce({
but text area side.
textarea Length="22681" cols="20" id="ResolutionsList_0__Resolutions" name="ResolutionsList[0].Resolutions" rows="2"
as u can see the id is not correctly generate normal MVC case.
$('#References').tinymce({
...
textarea Length="99" cols="20" id="References" name="References" rows="2"
then correctly generated.
Please give me some tips how can I control tinyMCE ids. thanks.
Ps. Here is TinyMCE_JQuery_Full.cshtml
$('#@ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)').tinymce({
Upvotes: 0
Views: 796
Reputation: 9145
In your partial view, use ViewData.TemplateInfo.GetFullHtmlFieldId
instead of ViewData.TemplateInfo.GetFullHtmlFieldName
:
$('#@ViewData.TemplateInfo.GetFullHtmlFieldId(string.Empty)').tinymce({
// ...
})
Upvotes: 1