How insert the content with JavaScript ( textarea ).
-
For sample textarea and wordpress visual editor I use the code
var code = mythemes_get_shortcode( sh ); // return [posts count="3"/] jQuery(function(){ if( jQuery( 'div#wp-content-wrap' ).length && jQuery( 'div#wp-content-wrap' ).hasClass( 'html-active' ) ) { var text = jQuery( 'textarea#content' ).val(); jQuery( 'textarea#content' ).val( text + code ); } else{ if( typeof tinyMCE == 'object' ) tinyMCE.execCommand( 'mceInsertRawHTML', false, code ); } });When is installed the WP Editor plugin I try to use an additional code for the case with the textarea.
var mythemes_sh_editor; ... if( jQuery( 'div#wp-content-wrap' ).length && jQuery( 'div#wp-content-wrap' ).hasClass( 'html-active' ) ) { var text = jQuery( 'textarea#content' ).val(); jQuery( 'textarea#content' ).val( text + code ); if( typeof CodeMirror == 'function' && typeof mythemes_editor == 'undefined' ){ var textArea = document.getElementById('content'); var mythemes_editor = CodeMirror.fromTextArea( textArea ); mythemes_editor.getDoc().setValue( text + code ); } else if( typeof CodeMirror == 'function' ){ mythemes_editor.getDoc().setValue( text + code ); } } ...but unfortunately it does not work.
please, can you help me to make it to work correctly.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘How insert the content with JavaScript ( textarea ).’ is closed to new replies.