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

跟風遠走 提交于 2019-12-12 15:47:00

问题


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.


回答1:


$('body').click(function(event){

    if($(event.target).parents('#articleEditor').length <= 0)
         $('#articleEditor').hide();
})



回答2:


The solution to a similar problem wasn't working for me due to clicks in dialog widgets. I ended up using

$('body').click(function(event){

    if($(event.target).parents('#articleEditor').length <= 0 && $(event.target).parents('.cke_dialog').length <= 0)
         $('#articleEditor').hide();
})


来源:https://stackoverflow.com/questions/8208053/how-to-hide-ckeditor-when-we-click-outside-of-the-editor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!