简体   繁体   English

Telerik RadEditor添加片段以包含JavaScript

[英]Telerik RadEditor Add Snippets to Include JavaScript

I am trying to add some JavaScript to a Telerik RadEditor Snippets. 我正在尝试向Telerik RadEditor片段添加一些JavaScript。 The following code adds it to the RadEditor and works. 以下代码将其添加到RadEditor并可以运行。

When I run it and add the snippet to the RadEditor , it adds it. 当我运行它并将代码段添加到RadEditor ,它将添加它。 When I inspect the Video, the HTML elements shows the and below that the JavaScript code I added with snippet as well. 当我检查Video时,HTML元素显示和,以及下面添加的代码段的JavaScript代码。

if (indVideoLink != null)
{
    RadEditor1.Snippets.Add("VideoLink",
    "<video id=\"azuremediaplayer\" class=\"azuremediaplayer amp - default- skin amp - big - play - centered\" tabindex=\"0\"></video>\"" +
    "<script type=\"text/javascript\">var myOptions = {\"nativeControlsForTouch\": false,controls: true,autoplay: true,width: \"640\",height: \"400\",}" +
    "myPlayer = amp(\"azuremediaplayer\", myOptions);myPlayer.src([{\"src\":" + 
    "\"" + indVideoLink + "\",\"type\":  \"appication/vnd.ms.sstr+xml" + 
    "}]);" +
    "</script>");
}

<telerik:RadEditor ID="RadEditor1" Runat="server" Content='<%# Bind("InductionNotes") %>' 
ToolsFile="~/intranet/OHS/Tools.xml"  Width="800px" Height="400px" ContentAreaCssFile="~/Intranet/OHS/ContentEditor.css" OnLoad="RadEditor1_Load">
</telerik:RadEditor>

But then I save it to InductionNotes using a Command Button and it only saves the <video></video> and its contents. 但是然后我使用命令按钮将其保存到InductionNotes中,并且仅保存<video></video>及其内容。 How do I get the `RadEditor' to save the JavaScript? 如何获取“ RadEditor”以保存JavaScript?

The Tools.xml file contains the following in Snippet Tools.xml文件在代码片段中包含以下内容

<tool name="InsertSnippet"/>
</tools>

I thought I might have add something to the Tools.xml file but I am not sure. 我以为可能已经在Tools.xml文件中添加了一些内容,但不确定。

I should add that the RadGrid is in a DetailsView and everthing else is saving and working correctly. 我应该补充说RadGrid在DetailsView ,其他所有东西都可以保存并正常工作。

解决方案是此代码行,该代码禁用默认情况下启用的RemoveScripts筛选器。

RadEditor1.DisableFilter(Telerik.Web.UI.EditorFilters.RemoveScripts);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM