CuteEditor methods are not working when making it visible by code.

Last post 03-07-2013, 9:52 PM by Kenneth. 5 replies.
Sort Posts: Previous Next
  •  03-06-2013, 10:25 AM 76988

    CuteEditor methods are not working when making it visible by code.

    Hi Team,

     

    I have following requirement, I have two editors in my page. And both are in a thrid party container. I will make them visible and invisible through code.

     

    When i am making one container visible , and tried to access any cuteeditor methods  i am gettign exceptions.

     

    Though the container is visible i guess cuteeditor is still not initialized, Is there any property to initialize cuteeditor thrrough code. Visible property is not working. This issue persists with every browser.

     

    Regards,

    Swathi 

    Filed under:
  •  03-06-2013, 12:59 PM 76989 in reply to 76988

    Re: CuteEditor methods are not working when making it visible by code.

    Hi swathiVajja,

     

    Before the editor load complete, can not access any of the client API of it.

     

    I suggest you hide the container after the editor load complete in "CuteEditor_OnInitialized".

     

    1. <script>  
    2. function CuteEditor_OnInitialized(editor)  
    3. {  
    4.   //hide the container here  
    5. }  
    6. </script>  

    Maybe you can share your code here, so we can check it for you too.

     

    Regards,

     

    Ken 

  •  03-07-2013, 6:22 AM 76995 in reply to 76989

    Re: CuteEditor methods are not working when making it visible by code.

    Hi Ken,

    I am adding cuteeditor dynamically to the page, How can i assign Intialized event for cute editor in clientside. Is there any way to make cuteeditor intialize rather than waiting for page to load.

     

    In 6.3 version i am not gettign any error in IE10 though its not working for any other browser. For 6.6 version no browser is supporting.

     

    C# code:

      HTMLBox1.ID = "HTMLBox" + Language;
                HTMLBox1.Height = Unit.Pixel(330);
                HTMLBox1.Width = Unit.Pixel(740);
                HTMLBox1.Attributes.Add("Initialized", "CuteEditor_OnInitialized(this);");
                HTMLBox1.ResizeMode = CuteEditor.EditorResizeMode.None;
                HTMLBox1.EnableStripStyleTagsCodeInjection = false;


                HTMLBox1.EnableAntiSpamEmailEncoder = false;
                HTMLBox1.EnableStripIframeTags = false;
                HTMLBox1.EnableStripLinkTagsCodeInjection = false;
                HTMLBox1.EnableStripScriptTags = false;
                //HTMLBox1.AllowPasteHtml = false;
                HTMLBox1.EditorOnPaste = CuteEditor.PasteBehavior.Default;
                HTMLBox1.EditorWysiwygModeCss = "~/includes/styles/editorStyle.css";
                HTMLBox1.EnableContextMenu = false;
                HTMLBox1.ConfigurationPath = "~/CuteSoft_Client/CuteEditor/Configuration/AutoConfigure/mailwizard.config";


                //HTMLBox1.ActiveTab = CuteEditor.TabType.Edit;
                //HTMLBox1.ShowBottomBar = false;
                HTMLBox1.ShowDecreaseButton = false;
                HTMLBox1.ShowEnlargeButton = false;
                //HTMLBox1.Initialized += new EventHandler(CuteEditor_OnInitialized);
                PvHTML.Controls.Add(HTMLBox1);
     

     JS code:

       var editor1 = $('HTMLBox' + LanguageID + '_ID');
        var editor2 = $('txtPlainText' + LanguageID + '_ID');

     TextResultID = GetTemplateText(TempID, 'PlainText');
            HTMLResultID = GetTemplateText(TempID, 'HTML');
            EmailSubject = GetTemplateText(TempID, 'Subject');


            if (TextResultID != "" && HTMLResultID != "") {
                selindex.selectedIndex = 0;
               setEmailType();// Making containers visible or invisible
            }
            else if (TextResultID != "") {
                selindex.selectedIndex = 1;
                setEmailType();
            }
            else if (HTMLResultID != "") {
                selindex.selectedIndex = 2;
                setEmailType();
            }




        }
       
        
        //    alert(editor1);
        //    alert(editor2);
        getObject('txtSubjectText' + LanguageID).value = EmailSubject;


        if (editor1 != null && HTMLResultID != '') {
            alert(editor1.Visible);
            alert(editor1.IsReady);
            var control = document.getElementById('CE_ctl00_contentMain_HTMLBox0_ID_ToolBar');
            alert(control);
            control.focus();
            try {
                editor1.FocusDocument();// Cute editor still not renedered at this point
                editor1.setHTML(HTMLResultID);
            }
            catch (e) {
                //editor1.AutoConfigure(Minimal);
                editor1.FocusDocument();
                editor1.setHTML(HTMLResultID);
            }
        }
        if (editor2 != null && TextResultID != '') {
            alert(editor2.Visible);
            alert(editor2.IsReady);
            editor2.FocusDocument();
            editor2.setHTML(TextResultID);
        }
    function CuteEditor_OnInitialized(editor) {
        alert('something');
    }
    error:

    Uncaught TypeError: Object #<HTMLTableElement> has no method 'FocusDocument'
     Let me know if you need anymore info.

     

     

    Edit: var control = document.getElementById('CE_ctl00_contentMain_HTMLBox0_ID_ToolBar');
         
            control.style.display = '';

            var control = document.getElementById('CE_ctl00_contentMain_HTMLBox0_ID_CodeViewToolBar');
            control.style.display = '';
            control.focus();
            var control = $('CE_ctl00_contentMain_HTMLBox0_ID_Frame');
            try {

                control.innerHTML = HTMLResultID;
                control.document = HTMLResultID;
            }
     I tried doing this, With this even though i can see the cuteeditor, I still can not see the data i assigned to iframe within.

  •  03-07-2013, 12:08 PM 76996 in reply to 76995

    Re: CuteEditor methods are not working when making it visible by code.

    Hi,

     

    You do not need to fire the "CuteEditor_OnInitialized", it will fire automatically when the editor load. For now has no way to fire it in code, so you must wait for the page load. What I mean to hide the container when the editor load, is like the example below. I hide the div1 in the "CuteEditor_OnInitialized".

     

    1. <%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" %>  
    2.   
    3. <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>  
    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 id="Head1" runat="server">  
    7.     <title></title>  
    8. </head>  
    9. <body>  
    10.     <form id="form1" runat="server">  
    11.         <div id="div1">  
    12.             <CE:Editor ID="editor1" runat="server" />  
    13.         </div>  
    14.     </form>  
    15. </body>  
    16. </html>  
    17.   
    18. <script>  
    19. function CuteEditor_OnInitialized(editor)  
    20. {  
    21.   //hide the container here  
    22.   var div1=document.getElementById("div1");  
    23.   div1.style.display="none";  
    24. }  
    25. </script>  
     

    Regards,

     

    Ken 

  •  03-07-2013, 12:47 PM 76998 in reply to 76996

    Re: CuteEditor methods are not working when making it visible by code.

    Hi Ken,

     

    Thanks for the reply, Some how that event is not firing in my page, I have 6 to 8 cute editors in my page, which will be invisible while page loads, and based on user selection they will be dispalyed.

     

     This issue is only with chrome , safari and firefox (May be other than IE) . I am trying to find a workaround for this.

     var control = document.getElementById('CE_ctl00_contentMain_HTMLBox0_ID_ToolBar');
     
            control.style.display = '';


            var control = document.getElementById('CE_ctl00_contentMain_HTMLBox0_ID_CodeViewToolBar');
            control.style.display = '';

            var control = $('CE_ctl00_contentMain_HTMLBox0_ID_Frame');
            try {

                iframeDocument = control.contentDocument ?
            control.contentDocument : control.contentWindow.document,
        iframeNewDiv = iframeDocument.createElement('div');


                iframeNewDiv.innerHTML = HTMLResultID;
                iframeDocument.body.appendChild(iframeNewDiv);
                iframeDocument.close();
                //control.innerHTML = HTMLResultID;
                //control.document = HTMLResultID;
            }
     Though i am able to copy the data into iframe, Its not staying . It is kinda flickering once. when i am clicking the button again it is staying. Any thoughts on this.

     

    In simple words my requirement is:

    I have two cute editors in my page plain text and html , Intially plaintext cute editor will be visible . If user try to copy a template , if that template contains only html. I need to make plaintext cuteeditor invisible and html cuteeditor visible and need to copy the template text into it. Even though i am making the html container visible cute editor is rendering as HTML table.  If user try to apply HTML template again its workign fine.

  •  03-07-2013, 9:52 PM 77002 in reply to 76998

    Re: CuteEditor methods are not working when making it visible by code.

    Hi swathiVajja,

     

    As I said, this api only fire when the editor load complete. You hide the editor by default, so this api will not fire. This is why I told you do not hide the editor by default. and hide it in this api like the exmaple page I provide.

     

    another way is that, before you try to using api method of the editor, you nee dto makes it show up first. or use it in the style "visibility:hidden", this will not cauess this error.

     

        <div id="div1" style="visibility:hidden">
                <CE:Editor ID="editor1" runat="server" />
            </div>
     

     

    Regards,

     

    Ken 

View as RSS news feed in XML