Toggle editor with Javascript

Last post 02-03-2010, 4:37 PM by Misha999. 2 replies.
Sort Posts: Previous Next
  •  01-30-2010, 9:06 AM 58456

    Toggle editor with Javascript

    I want to be able to hide/show the editor using javascript. the editor is currently in a modal popupextender and I was actually setting it to visible then showing it in the code behind but the post back is expensive.  I dont want to hide/show div like in this example http://richtextbox.com/userExample/hideshowdiv.aspx# - I just want to hide show the editor via javascript.  can it use the display style property to do this?
    Filed under:
  •  02-01-2010, 4:28 AM 58470 in reply to 58456

    Re: Toggle editor with Javascript

    Hi Misha999,
     
    Try
     
    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. <html xmlns="http://www.w3.org/1999/xhtml">   
    6. <head runat="server">   
    7.     <title>Untitled Page</title>   
    8. </head>   
    9. <body>   
    10.     <form id="form1" runat="server">   
    11.         <input type="button" value="hide" onclick="hide()" />   
    12.         <input type="button" value="show" onclick="show()" />   
    13.         <CE:Editor ID="editor1" runat="server" Style="display: none">   
    14.         </CE:Editor>   
    15.     </form>   
    16. </body>   
    17. </html>   
    18.   
    19. <script>   
    20. var editor1=document.getElementById("<%= editor1.ClientID %>");   
    21. function hide()   
    22. {   
    23.     editor1.style.display="none";   
    24. }   
    25. function show()   
    26. {   
    27.     editor1.style.display="block";   
    28. }   
    29. </script>  
    Regards,
     
    ken
  •  02-03-2010, 4:37 PM 58521 in reply to 58470

    Re: Toggle editor with Javascript

    Ok that works great, but I assumed that would decrease the download time of the page.  I have several editors on the page and the page is creating every single one of them every time the page loads, which is taking about 20 seconds (way too long).  I am launching them via javascript.  Is there a setting on the editor to load it on demand or something like that? I dont want a post back either.  What is your solution for someone who has a number of editors on the page?
View as RSS news feed in XML