Please help us to make AbanteCart Ideal Open Source Ecommerce Solution for everyone.

Support AbanteCart eCommerce

Author Topic: Correct Problem With More Than One Instance of 'texteditor' on Page.  (Read 9021 times)

Offline dhigz

  • Newbie
  • *
  • Posts: 46
  • Karma: +17/-0
    • View Profile
There is an inherent problem in AbanteCart with having more than one tinymce editor loaded on a single page. I have an extension where I need to have multiple instances of tinymce loaded. There may be other developers with the same issue.

In the admin/view/template/form/text_editor.tpl file which loads the instance tinymce for each texteditor form field type, the first command in the javascript portion is to remove all existing instances of tinymce on the page. This is correct in the creation of the custom tinymce editor used in AbanteCart. However, when the second instance is added it also removes the first, third removes the first and second, etc. While the editor looks and works right for the HTML/Text portion, the Visual portion will only work on the last instance added.

The solution is to remove the specific instance being loaded. Instead of tinymce.remove(), replace with tinymce.remove('textarea#text_editor_<?php echo $id ?>').

Now all instances of tinymce will work correctly. Please make this change in the next release.
Don Higbee

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 5964
  • Karma: +284/-2
    • View Profile
Re: Correct Problem With More Than One Instance of 'texteditor' on Page.
« Reply #1 on: March 30, 2020, 04:30:53 AM »
Thank you for suggestion

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 5964
  • Karma: +284/-2
    • View Profile

Offline dhigz

  • Newbie
  • *
  • Posts: 46
  • Karma: +17/-0
    • View Profile
Re: Correct Problem With More Than One Instance of 'texteditor' on Page.
« Reply #3 on: April 11, 2020, 11:11:02 PM »
Thanks Basara,

I pretty much came up with the same solution of changing the
value = tinyMCE.activeEditor.getContent();
to
value = tinymce.get('text_editor_<?php echo $id ?>').getContent()

I also changed it in the else statement
} else {
            $('#'+newtab_id+ ' textarea')
                  .val(textarea.val())
                  .removeAttr('disabled');
            if(tinyMCE.activeEditor != null) {
               value = textarea.val();
               value = html2visual(value);
               tinyMCE.activeEditor.setContent( value );
            }

Thanks for making the change.
Don Higbee

 

Powered by SMFPacks Social Login Mod