最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Adding hover event to elements inside a tinymce editor - Stack Overflow

matteradmin6PV0评论

I have a tinymce plugin that populates the editor with content.

Certain populated elements have a class="hoverable"

I'd like to attach a function to the hover event on those elements with class="hoverable"

I know how to attach an onClick with ed.onClick.add in the create function but there is no ed.onHover.add or ed.onMouseIn.add.

Edit: My plug-in actually pops up a dialog when you press the plug-in button in the menu. The user selects some content from the dialog and inserts it into the editor.

I have a tinymce plugin that populates the editor with content.

Certain populated elements have a class="hoverable"

I'd like to attach a function to the hover event on those elements with class="hoverable"

I know how to attach an onClick with ed.onClick.add in the create function but there is no ed.onHover.add or ed.onMouseIn.add.

Edit: My plug-in actually pops up a dialog when you press the plug-in button in the menu. The user selects some content from the dialog and inserts it into the editor.

Share Improve this question edited Oct 26, 2011 at 18:21 Hector Scout asked Oct 25, 2011 at 19:58 Hector ScoutHector Scout 1,4083 gold badges15 silver badges31 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

You can add a mouseover handler to elements in the editor with class 'hoverable'.

$(ed.getBody()).find('.hoverable').hover(function (evt){ /* do tooltip here */   });

You can find a howto create simple tooltips using jQuery here.

In the function that adds the selected content to the editor I added

tinymce.activeEditor.$('.hoverable').live('mouseover mouseout', function(evt) {
    if (evt.type == 'mouseover') {
        //do hover stuff
    }
    else {
        //undo hover stuff
    }
}

In my case new hoverable things may be added so I need the .live in other cases you could probalby just use .hover.

Post a comment

comment list (0)

  1. No comments so far