Reputation: 9645
I've written a TinyMCE plugin and I need to pass a variable to it from my app.
I've tried setting tinymce.activeEditor.my_var = 3;
after tinymce.init();
. In the plugin, editor.my_var
is always undefined.
How can I encode my own variable?
Upvotes: 3
Views: 4125
Reputation: 9645
I found the solution.
When initialising the editor, you can pass it a custom variable, like so.
tinymce.init({
selector: '#editor_html',
valid_elements: '*[*]',
plugins: [
"my_custom_plugin"
],
my_custom_variable: 'test',
});
then in the plugin you should be able to access the variable with the following code:
editor.getParam("my_custom_variable");
Alternatively, you can use an ajax request to set a session variable, and then have the plugin also perform an ajax request to retrieve the session variable.
Upvotes: 16