jquery - Set a JavaScript ondblclick event to a class inside tinyMCE editor -
some words in tinymce textarea editor in span tag specific class called "myclass". instance, word hello visible in tinymce textarea editor in source code following html code:
<span class="myclass" id="hello">hello</span>
i try launch function on double click on word hello.
the usual jquery code not work words inside tinymce editor:
$(document).ready(function() { $('.myclass').dblclick(function() { alert('class found'); }); });
the function not fire when double click on word hello in editor.
how can bind function tinymce editor?
tinymce uses iframe
element, cannot use $('.myclass')
on "main" scope in order elements inside iframe (the content of iframe different scope).
instead - need run $('.myclass').dblclick
in scope of iframe.
to can use setup
callback , editor.on("init"
event tinymce gives you:
tinymce.init({ selector:'textarea', setup: function(editor) { editor.on("init", function(){ editor.$('p').on('dblclick', function() { alert('double clicked'); }); }); } });
live demo here.
note
editor.$
notjquery
object, cannot used jquery, it's pretty close.
Comments
Post a Comment