Using the tiny MCE editor template in ASP.NET MVC provided as sample via Nuget. In this template there is a call to tinymce method as below:
$('#@ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)').tinymce({ . . . });
At runtime this changes to
$('#fieldId').tinymce({ . . . });
It was working fine until the property which this was targeting was in the model itself. But when I moved the property inside another property, it stopped working. Now the field is like ModelView.SomeModel.TinyMceField.
I looked at the code that was rendered, it is:
$('#MyModel.Description').tinymce({. . .});
Earlier this was:
$('#Description').tinymce({. . .});
The field id changed from Description
to MyModel_Description
. So the issue is the different ("." (dot) and "_" (underscore)) "id" used in textarea and tinymce method call.
How to solve this ? What should I change in :
$('#@ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)').tinymce({ . . . });
Got the solution:
$('#@ViewData.TemplateInfo.GetFullHtmlFieldId(string.Empty)').tinymce({. . .})