getHTML() doesn't work when Cute Editor is in a hidden div

Last post 08-21-2009, 9:19 AM by Adam. 8 replies.
Sort Posts: Previous Next
  •  08-19-2009, 2:16 AM 54772

    getHTML() doesn't work when Cute Editor is in a hidden div

    Hello, again,
     
    My app creates editors dynamically to suit each user's language preference, one editor per language, laid out in a tabbed set of divs.  The problem I'm having is that I can't use the "getHTML()" method of any editors that have not been made visible in the window yet.
     
    Per a previous post, I created a JScript method that finds the "1x1.gif" img element in each editor, and then invokes its "onclick" event.  This causes the CuteEditorInitialize() function to run, but none of the Editor specific methods or properties are made available.
     
    Is there a way to force the editor to initialize as it's being loaded rather than waiting until it is being displayed?
     
    Bruce 
  •  08-19-2009, 3:11 AM 54774 in reply to 54772

    Re: getHTML() doesn't work when Cute Editor is in a hidden div

    Hi BruceWMorgan,
     
    I can not reproduce this issue.
     
    Please tye the example below
     
    1. <%@ Page Language="C#" %>   
    2.   
    3. <%@ Register Assembly="CuteEditor" Namespace="CuteEditor" TagPrefix="CE" %>   
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
    5.   
    6. <script runat="server">   
    7.     protected override void OnLoad(EventArgs e)   
    8.     {   
    9.         editor1.Text = "this is a test";   
    10.         base.OnLoad(e);   
    11.     }   
    12.     
    13. </script>   
    14.   
    15. <html xmlns="http://www.w3.org/1999/xhtml">   
    16. <head id="Head1" runat="server">   
    17.     <title>test</title>   
    18. </head>   
    19. <body>   
    20.     <form id="form1" runat="server">   
    21.     <div style="visibility: hidden">   
    22.         <CE:Editor ID="editor1" runat="server">   
    23.         </CE:Editor>   
    24.     </div>   
    25.     <input type="button" value="ShowEditorText" onclick="show()" />   
    26.     </form>   
    27. </body>   
    28. </html>   
    29.   
    30. <script type="text/javascript">   
    31. function show()   
    32. {   
    33. var editor1=document.getElementById('<%= editor1.ClientID %>');   
    34. alert(editor1.getHTML());   
    35.   
    36. }   
    37. </script>  
    Regards,
     
    Ken
  •  08-19-2009, 3:31 AM 54777 in reply to 54774

    Re: getHTML() doesn't work when Cute Editor is in a hidden div

    Hello, Kenneth,
     
    My problem is not with static editors like in your example.  I cannot get the getHTML() method to word on editor controls that are dynamically generated at runtime if they are in a DIV where "style.display='none'" unless the div is made visible at least once.  Depending on the nature of the document that is being created, there may be many editors added to individual divs as the page loads.
     
    Until a user clicks on one of my tabs so that the editor in that tab becomes visible, the getHTML() does not work for that editor.  It returns a JScript error of "Object doesn't support this property or method."
     
  •  08-19-2009, 3:41 AM 54780 in reply to 54777

    Re: getHTML() doesn't work when Cute Editor is in a hidden div

    Update:  This does work when using "style.visibility = 'hidden'," but we are in need of "style.display='none'".
     
  •  08-19-2009, 3:45 AM 54781 in reply to 54777

    Re: getHTML() doesn't work when Cute Editor is in a hidden div

    HI BruceWMorgan,
     
    Before you use API getHTML() and SetHTML() you need to make sure Editor instance exists.
     
    Please add the code below in your page and try again.
    1. <script runat="server">   
    2.     
    3.     public string loaderName;   
    4.   
    5.     protected override void OnInit(EventArgs e)   
    6.     {   
    7.         base.OnInit(e);   
    8.         System.Web.HttpBrowserCapabilities browser = Request.Browser;   
    9.         string browserName = browser.Browser;   
    10.   
    11.         switch (browserName)   
    12.         {   
    13.             case "IE":   
    14.                 loaderName = "IE_Loader";   
    15.                 break;   
    16.             case "Firefox":   
    17.                 loaderName = "Gecko_Loader";   
    18.                 break;   
    19.             case "AppleMAC-Safari":   
    20.                 loaderName = "Safari_Loader";   
    21.                 break;   
    22.             case "Opera":   
    23.                 loaderName = "Opera_Loader";   
    24.                 break;   
    25.             default:   
    26.                 break;   
    27.         }   
    28.   
    29.     }   
    30.        
    31. </script>   
    32.   
    33. <script src="CuteSoft_Client/CuteEditor/Scripts/spell.js"></script>   
    34.   
    35. <script src="CuteSoft_Client/CuteEditor/Scripts/<%=loaderName %>/Loader.js"></script>  

    Regards,
     
    Ken
  •  08-19-2009, 3:57 AM 54784 in reply to 54781

    Re: getHTML() doesn't work when Cute Editor is in a hidden div

    That made no change.
  •  08-19-2009, 4:01 AM 54786 in reply to 54784

    Re: getHTML() doesn't work when Cute Editor is in a hidden div

    Hi BruceWmorgan,
     
    Please create an example can reproduce this issue and send it to me.
     
     
    Regards,
     
    Ken
  •  08-20-2009, 9:54 AM 54853 in reply to 54786

    Re: getHTML() doesn't work when Cute Editor is in a hidden div

    Kenneth,
     
    We you able to get the test application I sent over?
     
    Let me know if there's anything else I can do to get information to you.
     
     
    Bruce
  •  08-21-2009, 9:19 AM 54897 in reply to 54853

    Re: getHTML() doesn't work when Cute Editor is in a hidden div

    Bruce,
     
    An element can be hidden in two ways: by setting elem.style.display to “none”, or elem.style.visibility to “hidden”. The difference between the two is that setting visibility hides the element but it still is in DOM tree. Setting display to none will hide the element completely. Element doesn't actually appear in the DOM elements tree.
     
    Elements with display="none" cannot be accessed. That's why GetHtml will not work for this situation directly.
     
    Here is the only option:
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

View as RSS news feed in XML