EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Pierre on November 28, 2017, 02:59:43 PM



Title: [SOLVED] Enable right click on texteditor
Post by: Pierre on November 28, 2017, 02:59:43 PM
Hello
I'm using this code in my index.html file, to prevent using right-click except on editing fields:

Code:
  <script type="text/javascript">
    $(document).ready(function(data){
       $(document).bind('contextmenu',function(e){
        var t = $(e.target).closest('#editor,.validatebox-text');   // enable right click on HTML editor and all input's
        if (!t.length){
          e.preventDefault();    
        }
      });      
    });
  </script>  

question is - how to enable right-click on texteditor, too?
Thank you


Title: Re: Enable right click on texteditor
Post by: stworthy on November 28, 2017, 08:45:50 PM
Try this code.
Code:
<script type="text/javascript">
$(document).ready(function(data){
   $(document).bind('contextmenu',function(e){
    var t = $(e.target).closest('#editor,.validatebox-text,.texteditor-body');   // enable right click on HTML editor and all input's
    if (!t.length){
      e.preventDefault();   
    }
  });     
});
</script> 


Title: Re: Enable right click on texteditor
Post by: Pierre on November 28, 2017, 11:22:46 PM
Thank you for your answer but it does not work  :(


Title: Re: Enable right click on texteditor
Post by: stworthy on November 29, 2017, 12:21:24 AM
Please refer to this example http://code.reloado.com/ecipez4/edit#preview. The user can only right click on the textbox and texteditor components.


Title: Re: Enable right click on texteditor
Post by: Pierre on November 29, 2017, 01:14:38 AM
Yes it works perfect, it was my mistake.
Thank you so much for your help.