如何使用嵌套的财产在tinyMCE的ASP.NET MVC工作嵌套、如何使用、财产、工作

2023-09-07 08:55:59 作者:终不来

使用通过的NuGet作为样品的ASP.NET MVC的小MCE编辑模板。 在这个模板有如下在TinyMCE方法的调用:

  $('#@ ViewData.TemplateInfo.GetFullHtmlFieldName(的String.Empty))的TinyMCE({...});
 

在运行时,这会更改

  $('#fieldId)TinyMCE的。({...});
 

这是工作的罚款,直到这本是针对财产是模型本身。但是,当我提出内的财产另一个属性,它停止工作。现在现场就像是ModelView.SomeModel.TinyMceField。

我看着被呈现的code,它是:

  $('#MyModel.Description)的TinyMCE({...});
 
千万房产被别人办了房产证 工作人员 前任领导失误

此前,这是:

  $('#说明)的TinyMCE({...});
 

ID字段从说明更改为 MyModel_Description 。所以,问题是不同的(。(点)和_(下划线))的文本区域和TinyMCE的方法调用中使用身份证。

如何解决此问题? 我应该改变:

  $('#@ ViewData.TemplateInfo.GetFullHtmlFieldName(的String.Empty))的TinyMCE({...});
 

解决方案

得到了解决:

  $('#@ ViewData.TemplateInfo.GetFullHtmlFieldId(的String.Empty))。TinyMCE的({...})
 

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({. . .})