Re: Adding code snippets in JavaScirpt

  •  12-11-2013, 8:22 AM

    Re: Adding code snippets in JavaScirpt

    Hi frJericho,

     

    Please try the example below. It shows you how to add the code snippets dynamically in javascript.

     

    If you want to add it in server side code, please refer to http://richtexteditor.com/document/scr/html/code-snippets-dropdown.htm 

     

    1. <%@ Page Language="c#" ValidateRequest="false" %>  
    2.   
    3. <%@ Register TagPrefix="RTE" Namespace="RTE" Assembly="RichTextEditor" %>  
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    5. <html xmlns="http://www.w3.org/1999/xhtml">  
    6. <head>  
    7.     <title>example</title>  
    8. </head>  
    9.   
    10. <body>  
    11.     <form id="Form1" method="post" runat="server">  
    12.   
    13.         <RTE:Editor ID="editor1" runat="server"/>  
    14.        <input type="button" value="add custom template" onclick="addCustomTemplate()" />  
    15.     </form>  
    16. </body>  
    17. </html>  
    18.   
    19. <script type="text/javascript">  
    20.     var editor1;  
    21.     function RichTextEditor_OnLoad(editor) {  
    22.         editor1 = editor;  
    23.     }  
    24.     function addCustomTemplate()  
    25.     {  
    26.          editor1.LoadTemplates(function (group) {  
    27.             group.groups.push({  
    28.                 text: "custom group", groups: [], templates: [  
    29.                     { text: "sub template", href: "",code:"template text 1" }  
    30.                 ]  
    31.             });  
    32.             group.templates.push({  
    33.                 text: "my Template", href: "",code:"template text 2"  
    34.             });  
    35.         });  
    36.     }  
    37.   
    38. </script>  
     

    Regards,

     

    Ken 

View Complete Thread