summernote / summernote

Super simple WYSIWYG editor
https://summernote.org
MIT License
11.59k stars 2.25k forks source link

Loading via ajax modal - works every other time #4680

Closed uncdubdiver closed 1 month ago

uncdubdiver commented 2 months ago

Checklist

Steps to reproduce

More details in the "Current Behavior" section below.

  1. Click on a button, opens an ajax populated modal and on document ready, it instantiates the summernote WYSIWYG the first time.
  2. Close the modal, and repeat by clicking on the same (or another button), opens a modal, however the summernote WYSIWYG doesn't load, it's just the HTML code displayed like a normal textarea.
  3. Close the modal, and repeat by clicking on the same (or another button), opens a modal, however this time, the summernote WYSIWYG does load properly.

Expected behavior

It should reload the textarea WYSIWYG every single time.

Current behavior

Every other time I ajax load a BS3 modal, the WYSIWYG loads then doesn't the next, then does, then doesn't, etc...

  1. Click on a button, opens a modal and on document ready, it instantiates the summernote WYSIWYG the first time.
  2. Close the modal, and repeat by clicking on the same (or another button), opens a modal, however the summernote WYSIWYG doesn't load, it's just the HTML code displayed like a normal textarea.
  3. Close the modal, and repeat by clicking on the same (or another button), opens a modal, however this time, the summernote WYSIWYG does load properly.

It's literally every other time the modal loads it "inits" summernote, and I can't figure out why.

I have tried using the same id on each load, as well as used completely unique textarea ids on each load, same output occurs.

I have tried having it execute ...summernote('destroy') before it, doesn't fix it. I tried doing ...summernote('reset') before it, it clears the textarea, but leaves it still as a standard textarea and not a summernote obj.

First time it loads (and every other time it loads). This is the correct behavior. image

Then from the second time the button is clicked, and every other after that, this is the INCORRECT behavior that is being displayed. image

Minimal example reproducing the issue

No response

Environment

uncdubdiver commented 1 month ago

Is this application no longer getting any support?

1der1 commented 1 month ago

@uncdubdiver, SummerNote is an HTML editor. You cannot paste a whole HTML page into SummerNote or any other HTML editor.

BTW: SummerNote is an open source project. Everybody can ask questions or provide answers. I am a user like you.

uncdubdiver commented 1 month ago

@1der1 well actually you can, but I'm not using it that way.

I have been using it in a way to be able to generate PDF files using TCPDF, and it works very well. I'll load up a static/hardcoded HTML string, make edits, etc., save it, then I can use TCPDF to generate a PDF from the saved content, and it works great.

However the DOM object doesn't reload properly if the content is loaded in via ajax. It loads once, then doesn't load the next time, then loads again. The only way I can get it to load every time is if I reload the whole page then open the SummerNote editor, it doesn't seem to work after the DOM already has it loaded up, and the destroy and/or reset function doesn't work.

guisantos commented 1 month ago

your issue could be related with scaping the html

uncdubdiver commented 1 month ago

No clue, unfortunately it works fine with Froala, however I can't get past this simple/major issue with SummerNote, so I'm going to just close this ticket, it doesn't look like it's repeatable to troubleshoot.

DaveEvans2022 commented 3 weeks ago

No answer on this? I have the same issue.

uncdubdiver commented 3 weeks ago

No answer on this? I have the same issue.

Nope nothing. I've decided to go another route because this is a complete show stopper for me.

GL on your end!