Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CKEditor - get element after click on context Menu

I added link to context menu of img in ckeditor, using this code CKEditor - Add Context Menu Item to Images

How can I get the information about the image, on which user clicked? For example the id of the image. Or the path. In order to process with the selected image.

like image 416
VGranin Avatar asked Feb 02 '17 21:02

VGranin


1 Answers

The solution was pretty easy.

$('body').on('contextmenu','img',function(){
var imgid = $(this).attr('id');
alert(imgid);
})

Using jquery to track click on image, we can save it's id to global variable. Then, inside the command of the plugin, to take the id that we saved before.

like image 181
VGranin Avatar answered Sep 24 '22 07:09

VGranin