How to Make Tinymce's Modal Dialogs Responsive

How to run TinyMCE in jQuery modal dialog?

I have this code and it works.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ejemplo</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-ui.js"></script>
<script type="text/javascript" src="tinymce/jquery.tinymce.min.js"></script>
<script type="text/javascript" src="tinymce/tinymce.min.js"></script>
<link href="jquery-ui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready(function() {
$('#txapublicacion').tinymce({
plugins : 'link'
});
//--------------------------------------
$("#lnk_mostrar_form").click(function() {
$("#dv_formulario").dialog("open");
return false;
});
//--------------------------------------
$("#dv_formulario").dialog({
autoOpen : false,
modal : true,
buttons : {
Buscar : function() {
$(this).dialog("close");
},
Cancelar : function() {
$(this).dialog("close");
}
},
close : function() {}
});
//-------------------------------------
});
</script>
</head>
<body>
<a id="lnk_mostrar_form" href="">Formulario</a>
<div id="dv_formulario" title="Ejemplo">
<form id="frm_buscar">
<textarea id="txapublicacion"></textarea>
</form>
</div>
</body>
</html>

TinyMCE Not initilizing on jqueryui modal dialog

After much trial and error I found the issue was because the dialog had a show and hide effect! removing these made the system work, so a work around for this was to show a loading screen while tinymce was initilizing.

Code test.html :




Untitled Document



<script type="text/javascript">
$(function(){
$('.newbutton').button({icons: {primary: "ui-icon-plusthick"}}).click(function(e){
e.preventDefault();
$('body').css({'overflow' : 'hidden'});
$('#newform').dialog({
show: "puff",
hide: "puff",
resizable: false,
height: 500,
width: 800,
modal: true,
beforeClose: function(){
if ($("textarea.tinymce").length) {
$('textarea.tinymce').tinymce().remove();
};
$(this).html(" ");
},
close: function(){
$('body').css({'overflow' : 'auto'});
$(this).html(" ");
$('#newform').dialog('destroy');
},
open: function(){
$('#newform').load("test2.html", function(){
$(this).css({"overflow": "hidden"});
$('.tinymceloader').css({"position": "absolute", "height": $(this).height()-16, "width": $(this).width() - 32, "z-index": 200, "background-color": "#ffffff"});
setTimeout("inittinymce(); $(this).css({\"overflow\": \"auto\"});", 500);
});
}
});

});

});
function inittinymce(){
$('textarea.tinymce').tinymce({
// Location of TinyMCE script
script_url : 'js/tiny_mce/tiny_mce.js',

// General options
theme : "advanced",
plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",

// Theme options
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true

});
setTimeout("$('.tinymceloader').hide();", 1000);

}
</script>

</head>

<body>
<button id="newbutton" class="newbutton">New</button>
<div id="newform" class="hide" title="Title"><!-- data loaded dynamically--></div>

</body>
</html>

Code test2.html:

<div class="tinymceloader">Loading</div>
<textarea class="tinymce" id="elm1" name="elm1" rows="15" cols="80" style="width: 80%">
<p>
This is some example text that you can edit inside the <strong>TinyMCE editor</strong>.
</p>
<p>
Nam nisi elit, cursus in rhoncus sit amet, pulvinar laoreet leo. Nam sed lectus quam, ut sagittis tellus. Quisque dignissim mauris a augue rutrum tempor. Donec vitae purus nec massa vestibulum ornare sit amet id tellus. Nunc quam mauris, fermentum nec lacinia eget, sollicitudin nec ante. Aliquam molestie volutpat dapibus. Nunc interdum viverra sodales. Morbi laoreet pulvinar gravida. Quisque ut turpis sagittis nunc accumsan vehicula. Duis elementum congue ultrices. Cras faucibus feugiat arcu quis lacinia. In hac habitasse platea dictumst. Pellentesque fermentum magna sit amet tellus varius ullamcorper. Vestibulum at urna augue, eget varius neque. Fusce facilisis venenatis dapibus. Integer non sem at arcu euismod tempor nec sed nisl. Morbi ultricies, mauris ut ultricies adipiscing, felis odio condimentum massa, et luctus est nunc nec eros.
</p>
</textarea>

TinyMCE doesn't work within jquery ui modal dialog, why?

I had this problem.

For starters, I strongly recommend you instantiate tinymce after the modal dialog is on screen. I found that tinyMCE would try to take up the "most effective" amount of space on screen so is in effect invisible and/or the whole screen depending on how the modal box is set up.

There is something else though, you might notice that after closing the dialog box, your ability to interact with the page is disabled within the area tinyMCE was present! It is possible that your page is already experiencing this behaviour.

What fixed the problem for me (although not so elegant but, after pulling out my hair) I chose to destroy the dialog box and be sure to hide tinymce after the form had recieved a pass response from the server.

There are two commands to use for this

  1. Nuke the dialog box from orbit

    $('#modal-dialog').dialog('destroy');
  2. Check for presence of tinymce and hide it if found

    if ($(".textarea").length) {
    $('.textarea').tinymce().hide();
    };

TinyMCE menus not working inside bootstrap modal

Add the folowing css

.tox-tinymce-aux {
z-index: 999999!important;
}

tinyMCE in an angularjs modal dialog only works on the first popup

From docs: https://github.com/angular-ui/ui-tinymce
Be sure not to set an id attribute.)

So just remove id:

    <textarea ui-tinymce="" ng-model="tinymceModel">{{SectionTemplate.Preface}}</textarea>

http://plnkr.co/edit/Mv2fLWuKiVjEIy77XNF0?p=preview



Related Topics



Leave a reply



Submit