Can we use variables in tinyMCE.init() ? I want to decide the available set of buttons on value of formatselect. Is this possible ?
A:
Yes, this is possible. You only have to make sure that this variables are accessible from the tinymce init function. For example:
var content_file = "/css/content.css";
tinyMCE.init({
// General options
mode : "textareas",
theme : "advanced",
plugins : "code,...",
content_css: content_file, // used here
language : 'de'
});
You may also use a scriptlanguage liek perl or php to dynamically create your javascript code.
Thariama
2010-07-07 11:56:07
Almost. The variable doesn't need to be accessible from with the init function, but from the code that calls it (or to be more specific, creates that list of settings)
Bart van Heukelom
2010-07-07 11:58:11
I'm trying this - buttonToolBar:"bold,italic"; tinyMCE.init({ mode : "exact", theme : "advanced", elements : "textAreaId", theme_advanced_toolbar_location : "top", theme_advanced_layout_manager: "SimpleLayout", theme_advanced_buttons1_add_before :"formatselect", plugins : "code", theme_advanced_disable :buttonToolBar });But it fails with error buttonToolBar not defined. :(
KutePHP
2010-07-07 12:21:59
@bart: you are right
Thariama
2010-07-07 12:23:08
@KutePHP: try: buttonToolBar = "bold,italic"; ('=' instead of ':' when setting the variable at the beginning)
Thariama
2010-07-07 12:26:36
init fails and no mce instance is loaded.
KutePHP
2010-07-07 12:36:25
does it gets inititialized when you do not use the parameter theme_advanced_disable at all?
Thariama
2010-07-07 13:01:34