Created
December 19, 2014 20:50
-
-
Save miteshmap/be86f9324336da8efaf2 to your computer and use it in GitHub Desktop.
Drupal - write value to textarea with editor with js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function ($) { | |
| Drupal.fooModule = Drupal.enrich || {}; | |
| Drupal.fooModule.copyToTextarea = function($field, $value, settings) { | |
| for (var editor in settings.wysiwyg.configs) break; | |
| $("textarea[name^='"+ $field +"']").val($.trim($value)); | |
| var editorid = $("textarea[name^='"+ $field +"'].text-full").attr('id'); | |
| if (typeof editorid != 'undefined' && editorid.length > 0) { | |
| if (editor == 'tinymce') { | |
| tinyMCE.execInstanceCommand(editorid, 'mceSetContent', false, $.trim(html)); | |
| } | |
| else if (editor == 'ckeditor') { | |
| CKEDITOR.instances[editorid].setData($.trim(html)); | |
| } | |
| } | |
| }; | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment