Using a node--add .tpl.php file I can implement a jQuery javascript call such as

var fieldTitle = $('#edit-title');
function titleChange() {window.alert(fieldTitle.val());}
fieldTitle.change( titleChange );

which creates an alert each time the title value is changed. As such, I know that I can obtain the form values from the edit form from where my script is being placed; however, I am unable to obtain the value from the text field which used CKEditor.

By using the #id for the text field, I can use .change() and have interactions occur as users type into the field. However, I'm unable to obtain the actual value from the text field. I've tried every ID of every tag nested in the field's div and used console.log() to output the field instance, the .val(), and even .html() with no success in even finding the value of the text typed into the ckeditor text area.

The only information on the internet that I was able to find appears to involve obtaining the value from ckeditor using CKEDITOR.instances however the console log error that occurs for any script involving this is "CKEDITOR" is not defined.

Does anyone know how to obtain a value from the CKEditor text area in Drupal using jQuery?

  • this question appears to be off-topic as it relates solely to JS, and not to Drupal – Geoff Jul 7 '15 at 0:11
  • This is referring specifically to obtaining field values with the Drupal CKEditor module which appears to be different in functionality than CKEditor in a non-drupal environment. – John Millnik Jul 7 '15 at 0:15

Your Answer

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

Browse other questions tagged or ask your own question.