title: Tinymce plugin executing based on how many clicks
body: <p>We added a custom image uploading code to the tinymce plugin. 
  It works like this: click on image icon in the tinymce toolbar, the popup appears with uploaded images and we can select the image from the popup by double clicking on it.</p>
  
  <p><strong>The problem is:</strong> when we select a image first time it loads one image, but when we process same procedure without refreshing the page second time it loads 2 images, on 3rd time it loads 3 images. </p>
  
  <pre><code>editor.execCommand('mceInsertContent', false, '&lt;img src=' + i + '&gt;');
  </code></pre>
  
  <p>it executes upon the clicking time of mouse like 1,2,etc. increased
  so I didn't understand what is the solution for this.</p>
  
  <p>Here is the plugin code:</p>
  
  <pre><code>tinymce.PluginManager.add('imggallery', function(editor) {
      editor.addCommand('Insert Image', function() {
          $("#myModal2").modal('toggle');
          $(".theme").dblclick(function(){
              var i = $(this).attr('src');
  
          $('&lt;img src=' + i + '&gt;').appendTo(editor.getBody());
          //editor.execCommand('mceInsertContent', false, '&lt;img src=' + i + '&gt;');
  
          //$("#myModal2").modal('toggle');
          $(".close").click();
  
  
          });
  
      });
  
      editor.addButton('imggallery', {
          icon: 'image',
          tooltip: 'Insert Image',
          cmd: 'Insert Image'
      });
  
  
  });
  </code></pre>