1
votes

I am trying to use tinyMCE in a ruby on rails application. This is my initialization code.

    <script type="text/javascript" src="/tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript">
        tinyMCE.init({
                // General options
                // script_url: '/tiny_mce/tiny_mce.js',
                mode : "textareas",
                theme : "advanced",
                plugins : "layer,inlinepopups",
                relative_urls : false, 
                theme_advanced_buttons3_add : "tablecontrols",
                table_styles : "Header 1=header1;Header 2=header2;Header 3=header3",
                table_cell_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Cell=tableCel1",
                table_row_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1",
                table_cell_limit : 100,
                table_row_limit : 5,
                table_col_limit : 5,

The initialization is working fine. Now, I am not using the tinyMCE toolbar, and instead have my own links, which when clicked, the tinyMCE functions for formatting text, inserting image, etc. should be invoked.

For instance, I have used tinyMCE table plugin, and need to insert table into the textarea when my page loads. This is what I tried:

editor = tinyMCE.get('editor');
editor.mceInsertTable();

But its not working. Please help.

Thanks.

2

2 Answers

1
votes

mceInsertTable is an execCommand. You will need to call the following

tinymce.activeEditor.execCommand('mceInsertTable');
1
votes

Sure, you just use the TinyMCE JavaScript API:

http://tinymce.moxiecode.com/js/tinymce/docs/api/index.html#

For example:

tinymce.activeEditor.hide();