JQuery and tinymce

I have the following javascript in a plugin.

AJS.bind(“rte.init.ui”, function() {
var body = AJS.$("#wysiwygTextarea_ifr").contents().find("#tinymce");

function showMacro(index, element) {

The console shows that “body” has 7 children, but the each() method appears to only be processing the first one. This is not the only issue I am having. The find() method only seems to find the first child, and if the selector does not match that first child, it finds nothing. I suspect they are related.

NOTE: body.find(*) only returns two elements. The first child, and it’s first child. The grandchild has no children.

NOTE: One possibility is the document is not fully loaded when “rte.init.ui” is called. If that is the case, what trigger should I bind to?

Solved. The appropriate binding point is rte-quick-edit-ready

AJS.bind("rte-quick-edit-ready", function() {
    var macros = AJS.$('#wysiwygTextarea_ifr').contents().find("#tinymce table.wysiwyg-macro");
    // work on the macros here

1 Like