Page 1 of 1
dynamic WYSIWYG?
Posted: Thu Feb 13, 2014 10:27 pm
by von-hamster
My form with textarea loading with AJAX, but if textarea with wysiwyg - it not worked.
Module generate Initial wysiwyg javascript file for static page with predefined textarea fields. Can I use (and how) standart functional for turn wysiwyg on any new created fields?
PS. Sorry 4 my english

Re: dynamic WYSIWYG?
Posted: Fri Feb 14, 2014 2:00 am
by JohnnyB
You might try the Advanced settings tab for TinyMCE. There is an option called, Extra Configurations.
You can try adding something like:
elements : "elm1,elm2"
Where elm1 is the div ID or class you need as a WYSIWYG.
There's also this:
http://www.tinymce.com/wiki.php/Configu ... r_selector
http://www.tinymce.com/wiki.php/Configu ... x:elements
Other than that, the alternative is setting TInyMCE to use a Static configuration file which is placed into the /tmp/ directory. Then you can manually edit the Javascript init() call in that file.
Re: dynamic WYSIWYG?
Posted: Fri Feb 14, 2014 8:30 am
by von-hamster
Thanks.
But my module has dynamic textarea id's, not predefined.
I found next solution:
1. On main page (for include tinymce scripts):
Code: Select all
$module = cms_utils::get_wysiwyg_module();
$module->wysiwygactive = true;
$module->WYSIWYGTextArea('fakeTextAreaForLoadTiny');
echo $module->WYSIWYGGenerateHeader();
2. for each textarea with wysiwyg add property: data-wysiwyg="true"
3. after ajax form load:
Code: Select all
// dlg - form container
$('textarea[data-wysiwyg="true"]', dlg).each(function(){
var tId = $(this).attr('id');
try {
var ins = tinyMCE.getInstanceById(tId);
if (ins) {
tinyMCE.remove(ins);
}
} catch(e) {
console.log(e);
}
tinyMCE.execCommand('mceAddControl', true, tId);
});