Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inline TinyMCE change input names

I'm creating a bunch of inline tinyMCE editors on some span tags, like so

<span class="editor">text here</span>

 <script type="text/javascript">
 tinymce.init({
        selector: ".editor",
        inline: true,
        object_resizing: false,
        toolbar: "undo redo",
        menubar: false,
        forced_root_block: false,
    });
</script>

But I want to make the hidden inputs it automatically generates named something other than mce_[number], so that it'll match what the cakePHP framework expects. I tried just changing the name attribute of those fields with javascript. Sometimes that works, and other times those input fields will not have any data when the form is submitted. Any help?

like image 584
Kai Avatar asked Jul 03 '13 00:07

Kai


People also ask

How do I change content in TinyMCE editor?

Running the setContent() function on specifically editorOne with the tinymce. get('editorOne'). setContent(contentOne); method, you can change just editorOne.

What is TinyMCE selector?

Selector engine, enables you to select controls by using CSS like expressions. We currently only support basic CSS expressions to reduce the size of the core and the ones we support should be enough for most cases.

How do I set HTML content in TinyMCE?

You can do this using the setContent() method from the TinyMCE API.


1 Answers

tinyMCE will automatically choose the id of div(or span in your case) to be name of hidden input. it will only use mce_# if id is not specified.

<span class="editor" id="DesiredName">text here</span>
like image 105
mtbnunu Avatar answered Sep 19 '22 06:09

mtbnunu