Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
81
rated 0 times [  85] [ 4]  / answers: 1 / hits: 22677  / 9 Years ago, fri, april 10, 2015, 12:00:00

Using WindowManager for TinyMCE I open a window and it writes back raw HTML. But its truncating my links for my images. Whats weird is that it does NOT do it to the anchor tag. Just the image tag.



I have this bit of code



html = '<a title='+ $('#title').val() +' href='+ $('#url').val() +'><img src='+ $('#imgURL').val() +' /></a>';

var parentEditor = parent.tinyMCE.activeEditor;
parentEditor.execCommand('mceInsertRawHTML', false, html);
parentEditor.windowManager.close();


It DOES insert the html into the active Editor. When I log html to the console I get



<a title=Click Action href=yahoo.com><img src=http://marketingedu.mychm.co/images/buttons/c2a-button4.png /></a>


However when I view the Source Code in the tinyMCE editor, it changed the images SRC attribute to



../../images/buttons/c2a-button4.png


Here is my entire javascript init for the TinyMCE editor



tinymce.init({
selector: .editor,
setup: function(ed) {
ed.on('change', function(e) {
tinyMCE.triggerSave();

$('form').trigger('checkform.areYouSure');
});
ed.on('init', function(e) {
autoresize_max_height: 500
});
ed.addButton('defaultbtn', {
title: 'Insert Button',
icon: 'fa fa-plus-square',
onclick: function() {
// Open window
ed.windowManager.open({
title: 'Button Selector',
url: <?=$this->url('/webinar/custombuttons') ?>,
width: 800,
height: 600
});
}
});
},
plugins: [
advlist autolink link responsivefilemanager lists charmap print preview hr anchor pagebreak spellchecker,
searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking,
save table contextmenu directionality template paste textcolor colorpicker responsivefilemanager autoresize
],
toolbar: undo redo | styleselect | bold italic | forecolor backcolor | alignleft aligncenter alignright | bullist numlist | outdent indent | table | link responsivefilemanager defaultbtn,
image_advtab: true ,

external_filemanager_path:/filemanager/,
filemanager_title:Filemanager ,
external_plugins: { filemanager : /filemanager/plugin.min.js},
});

More From » tinymce

 Answers
159

Change this:


var parentEditor = parent.tinyMCE.activeEditor;
parentEditor.execCommand('mceInsertRawHTML', false, html);

To This:


tinymce.activeEditor.setContent(html, {format: 'raw'});

Here is a reference link on how to set content on tinymce in various of ways.


Hope this helps.


[#67115] Wednesday, April 8, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
anders

Total Points: 295
Total Questions: 106
Total Answers: 104

Location: Angola
Member since Wed, Apr 13, 2022
2 Years ago
;