jqueryckeditorlostfocus

How to hide ckeditor when we click outside of the editor?


Here is my code:

<div id="showReplyDiv">
  <form id="test">
   <div>
       <textarea id="articleEditor" name="articleVO.articleC"></textarea>
           <script type="text/javascript">
            CKEDITOR.replace( 'articleEditor',{customConfig : '/Forum/ckeditor/replyCKEditor.js'}); 
        </script>
    </div>
    <div id="buttonArea">
        <input type="button" id="doReply" value="submit"/>
        <input type="button" id="cancel" value="cancel"/>
    </div>
    </form>
</div>

I want it so that when the user clicks anywhere outside of this ckEditor, I can hide it.


Solution

  • $('body').click(function(event){
    
        if($(event.target).parents('#articleEditor').length <= 0)
             $('#articleEditor').hide();
    })