4

I'm using EE 2.5.2 and Wygwam 2.6.3. I need to bind some custom javascript to a Wygwam field on the publish/edit screen in the CP once the field has initialised.

Specifically, I need to bind to something like this:

$(#cke_field_id_12).find('iframe').contents().find('body');

However as the iframe is created dynamically, I need to wait until after Wygwam has initialised for $(#cke_field_id_12) to have a child iframe plus contents for me to bind to.

Does CKEditor/Wygwam fire an event when it's ready that I can hook into to bind my functionality to? Or is the an alternative way to do this that I haven't thought of?

2

CKEditor’s instanceReady event ought to fit the bill for you:

http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.html#event:instanceReady

CKEDITOR.on('instanceReady', function(ev) {
    // ...
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.