views:

28

answers:

1

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
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
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
@bart: you are right
Thariama
@KutePHP: try: buttonToolBar = "bold,italic"; ('=' instead of ':' when setting the variable at the beginning)
Thariama
init fails and no mce instance is loaded.
KutePHP
does it gets inititialized when you do not use the parameter theme_advanced_disable at all?
Thariama