如果有某些字段使用 htmleditor 的要求。因此,对于使用 htmleditor 的每个字段,我创建了一个编辑器模板,该模板使用 jquery 呈现 htmleditor,为此我使用 UIHint。
@model System.String
<script type="text/javascript" src="~/Scripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" language="javascript">
tinyMCE.init({
mode: "textareas",
theme: "advanced",
editor_selector: "htmlmarker",
theme_advanced_buttons1: "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter, justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace, |,bullist,numlist,|,outdent,indent, blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code, |,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3: "hr,removeformat,visualaid,|,sub,sup",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left"
});
</script>
@Html.TextAreaFor(model => model, new {@class="htmlmarker" })
现在 evreything 工作正常,但是在执行时,当我查看源代码时,我发现 jquery 脚本被引用并为使用 UIHint 的每个字段多次调用。是否有任何机制来防止 javascript 代码的重复?