user1664043
user1664043

Reputation: 705

tinymce 3.5.4.1 adding event handlers, lots of errors

I'm adding a TinyMCE editor to one of our pages. For reasons above my pay-grade, we're using TinyMCE 3.5.4.1.

It's gone pretty well, except when I try to wire in an onFocus event handler. If I don't try to use the handler, the editors show up and work fine but on pages where I define a handler, there are boatloads of exceptions inside TinyMCE for the browser types I've tried (IE8,9,10 and Chrome).

I've been using templates from other posts I've seen on here but I haven't seen mention of all these TinyMCE exceptions. Of course, trying to unwind the minified script is a real pain.

The first example I found here had a setup function in the TinyMCE config like this:

 , setup: function (ed) {
      ed.onInit.add(function (ed, evt) {
      if (!myFocus) return; // global for the handler to use
         var dom = ed.dom;
         var doc = ed.getDoc();
         tinymce.dom.Event.add(doc, 'focus', myFocus);
      });
   }

When myFocus is defined, there are a number of exceptions TinyMCE throws starting with if (j.isIE){l.attachEvent(...)} complaining that l.attachEvent doesn't exist. Then it moves on to all kinds of variable type mismatches.

Chrome developer tools are much more awkward fiddling with minified code, so I'm not sure what all it doesn't like.

Another post I found here suggested doing some minimal browser detection but this helped neither IE nor Chrome.

var doc = s.content_editable ? ed.getBody() : (tinymce.isGecko ? ed.getDoc() : ed.getWin())

Another post suggested a different approach, but I still had all the same errors in both browsers.

, setup: function (ed) {
     ed.onInit.add(function (ed, evt) {
     if (!myFocus) return;
     ed.onFocus.add(myFocus);
     });
}

I've also just tried (in vain)

, setup: function (ed) {
      if (!myFocus) return;
      ed.onFocus.add(myFocus);
 }

Is event handling in TinyMCE just very fragile? Not well supported across browsers? Should I just steer clear of it and try using jQuery or something else?

Thanks Mark

Upvotes: 0

Views: 248

Answers (1)

user1664043
user1664043

Reputation: 705

Turns out to be a pilot-error bug being deferred until the extend calls created the editor.

Upvotes: 0

Related Questions