Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am working on calling a Node-Edit form via Ajax, and then having CKEditor take over the body field .
This is working, except that my toolbar is not listening to ckeditor/ckeditor/config.js .
The process is as follows:
1) jquery.load() the node-edit form
2) call "CKEDITOR.replace('name-of-form')"
How can I get the text editor to use the toolbars in config.js?
Comments
Comment #1
kvvnn CreditAttribution: kvvnn commentedComment #2
kvvnn CreditAttribution: kvvnn commentedFORWARD PROGRESS:
Instead of calling just "CKEDITOR.replace('form-name'), I used the following :
DrupalFiltered is defined in modules/ckeditor.config.js
But it does not seem like that toolbar is recognized by CKEDITOR. It looks as though its only looking in ckeditor/ckeditor/ckeditor.js
I am getting the error message:
Line 77 is :
P.S. Good docs can be found at : http://docs.cksource.com/CKEditor_3.x/Developers_Guide
Comment #3
kvvnn CreditAttribution: kvvnn commentedI've also tried doing a :
Drupal.attachBehaviors($('#my-ajax-form-container') after the form is loaded, but get the following:
Comment #4
kvvnn CreditAttribution: kvvnn commentedComment #5
kvvnn CreditAttribution: kvvnn commentedLooking at ckeditor.utils.js, it looks like the proper way to do this is to call Drupal.ckeditorOn('#my-textarea-id');
Doing that, I am getting no errors now, but also no action.
Help?
Comment #6
kvvnn CreditAttribution: kvvnn commentedI do not mean to bump relentlessly, but I am inching away and just want to get some things confirmed / denied.
I see that ckeditor_process_textarea within ckeditor.module seems to do some important things. Does this need to be called in order for a textarea to properly turn into a CKEditor field?
I guess I could use a menu_callback to do this from my JS or something?
Comment #7
mephir CreditAttribution: mephir commentedckeditor_process_textarea generates settings for ckeditor instances. ckeditorOn function fired up ckeditor instance with that settings. So using ckeditorOn without setting in table is unnecessary. You sholud use ckeditor.config.js instead of ckeditor/ckeditor/config.js which is ignored by module. Exactly i don't understand your problem. This issue is related with Ajax module ?
Comment #8
kvvnn CreditAttribution: kvvnn commentedHey Mephir.
Here is my issue :
1) I'm using CKEditor on the body field of a node
2) Its working perfectly if I go to www.site.com/node/12/edit
3) I pull in a node-edit form from the front page using : $('div#mydiv').load('node/12/edit #node-form')
4) The node-edit form gets pulled, but does not have a CKEditor instance on the body field
5) I can't figure out how to get CKEditor module to turn the body field into an instance
I've tried the following:
Drupal.ckeditorOn('body-edit');
Drupal.ckeditorToggle('body-edit');
Comment #9
mephir CreditAttribution: mephir commentedYes, you can use ckeditorOn for make instance, but you haven't got settings for that instance. I must think a while, how to help you with it, because if you are using jQuery.load it only replace one div by another. First think which i had, is using jQuery.get instead of load, and try to get settings for ckeditor from all document. Another thing, there might not be ckeditor and ckeditor.utils loaded. Because on main page ckeditor isn't running, so you must load them manually.
Comment #10
kvvnn CreditAttribution: kvvnn commentedI have loaded ckeditor and ckeditor.utils manually.
Definitely what is going on.
Thanks for your help, I look forward to hearing from you.
Comment #11
kvvnn CreditAttribution: kvvnn commentedMephir, if this issue needs to be sponsored, just let me know please.
Thanks,
Comment #12
kvvnn CreditAttribution: kvvnn commentedBy "settings" do you mean specifically Drupal.settings.ckeditor ?
Comment #13
mephir CreditAttribution: mephir commentedYes, there is some line in head which have ckeditor settings, if you see node/*/edit source, there is something like:
and the ckeditor object have got all settings for instances. You can use regular expressions to get this and extend Drupal object with all settings from edit page or get only ckeditor settings from them. For insert edit form you can also use regexp to get it and insert manually into page. If i had free time tomorrow evening i can write simple function for it.
Comment #14
kvvnn CreditAttribution: kvvnn commentedYaaarrrrrrrrrrrrrhhhhhhhhhhhhh!
Rejoice like the King you are, Mephir! Enjoy beautiful women with wine and a full moon!
Below is how I pulled a node-edit form w/ CKEditor attached via Ajax:
---------------------------------------------------------------
Prerequisites
A nodeblock (www.drupal.org/project/nodeblock) block, with a body field that uses CKEditor
A way to submit your form via Ajax .I'm using the Ajax module. This requires a line of code to re-initialize the JS for our form. It would be pretty easy to submit it using jQuery's ajax() tools, and I may edit this in the future so that Ajax module is not required.
1) I have a node block on my /node/51/edit page, using standard Block Admin
2) In my module's JS file, I have manipulated the block's "edit" link in the following way:
Thank you most graciously, Mephir.
Comment #15
kvvnn CreditAttribution: kvvnn commentedComment #16
kvvnn CreditAttribution: kvvnn commented