asp.net - How can I have two TinyMCE editors on the same page with different configurations -
i've been debugging whole day.
i have asp.net mvc project , tinymce editor template, problem last tinymce shown.
@html.textarea(string.empty, new { id = textareaid, value = viewdata.templateinfo.formattedmodelvalue }) <script type="text/javascript"> tinymce.init({ mode: "exact", elements: "textarea#@textareaid", theme: "modern", inline: true, plugins: [ "advlist autolink lists link image charmap print preview hr anchor pagebreak", "searchreplace wordcount visualblocks visualchars code fullscreen", "insertdatetime media nonbreaking save table contextmenu directionality", "template paste textcolor colorpicker textpattern imagetools" ], toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image", toolbar2: "preview media | forecolor backcolor code | ltr rtl", image_advtab: true, templates: [ { title: 'test template 1', content: 'test 1' }, { title: 'test template 2', content: 'test 2' } ], file_picker_callback: function (callback, value, meta) { if (meta.filetype === 'image') { $('#@formid input').click(); } } }); </script>
i'm calling editortemplate this:
@for (int = 0; < model.answers.count; i++) { @html.editorfor( model => model.answers[i].text, new { htmlattributes = new { @class = "form-control" }, textareaid = string.format("answer-textarea-{0}", i), formtargetid = string.format("answer-formtarget-{0}", i), formid = string.format("answer-form-{0}", i) }) }
so far i've been trying different modes, different selectors, downgraded tinymce 3.0 - no effect. solutions found far on internet don't work me. error getting in console theme not constructor, since changed mode exact , elements in config, last editor used shown (probably because tinymce.init overrides previous initializations or something) not shown , error. have no clue how solve this. appreciated.
you can absolutely have multiple editors different configurations.
as init()
call happening in browser real question asp code becoming when loaded browser.
to start not use tinymce 3 - old version of tinymce , no longer getting updates. example seems use elements
configuration option option tinymce 3 not tinymce 4 why not working @ tinymce 4 - should return using selector
option.
as tinymce 4 - should use selector
configuration option control configuration object <textarea>
:
https://www.tinymce.com/docs/configure/integration-and-setup/#selector
for example:
tinymce.init({ selector: "#area3", ... });
the selector option expects string equates css selector 1 or more elements on page. above example assumes 1 <textarea>
on page has id of area3
single <textarea>
replaced tinymce.
if trying create multiple configurations on fly via asp code need debug code this:
selector: "textarea#@textareaid"
is evaluated when sent browser. if @textareaid replaced valid id , end
selector: "textarea#abc123"
...then if such textarea exists tinymce replace it. suspect asp code providing browser not think tinymce not getting invoked. without seeing running can suggest you.
Comments
Post a Comment