2

I have added tinyMCE editor in Order status history for comment field, the issue is when i get ajax response, editor disappears instead its showing normal textarea field, please find below screenshots of tinyMce editor field and ajax response field respectively:

order history on landing page

order history while ajax comment

I have used below code in this page to use tinyMCE editor:

<textarea name="history[comment]"  id="history_comment" class="textarea" cols="80" rows="20"></textarea>
                <script>
                 require([
                    'jquery',
                    'mage/adminhtml/wysiwyg/tiny_mce/setup'
                ], function(jQuery){

                var config = {}, 
                    editor;

                jQuery.extend(config, {
                    settings: {
                        theme_advanced_buttons1 : 'bold,italic,|,justifyleft,justifycenter,justifyright,|,' +
                                                    'fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,bullist,numlist,|,code',
                        theme_advanced_buttons2: null,
                        theme_advanced_buttons3: null,
                        theme_advanced_buttons4: null
                    }
                });
                editor = new tinyMceWysiwygSetup(
                    'history_comment',
                    config
                );
                editor.turnOn();
                jQuery('#history_comment')
                    .addClass('wysiwyg-editor')
                    .data(
                        'wysiwygEditor',
                        editor
                    );
            }); 
                </script>
  • Please share your ajax code – kunj Oct 18 '18 at 4:13
  • Actually, this is default magento ajax request/response used for adding comment on order view page – bhargav shastri Oct 18 '18 at 9:40
  • Most probably your DOM is getting reset after the ajax call. Hope you have found the issue till now – Ashwani Shukla Oct 22 '18 at 12:57
  • @AshwaniShukla. Thanks for your reply. Yes, you got it right that DOM is being reset after ajax call. I have tried so many solutions till date but nothing worked unfortunately. You may guide me if you know any proper solution. – bhargav shastri Oct 22 '18 at 13:50
  • try to bind the editor using jquery "on" ( api.jquery.com/on ). And I will be able to help you more if you could please let me know the purpose of ajax and it's code. – Ashwani Shukla Oct 22 '18 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.