Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I initialise Quill on a textarea in a dynamically added div by Cocoon? #4

Open
siddhartharun opened this issue Jun 8, 2021 · 1 comment

Comments

@siddhartharun
Copy link

I'm using Cocoon to create a nested form. Cocoon offers the following method when the div is added to the DOM:

cocoon:after-insert

How might I initialise Quill on a textarea in the dynamic nested form?

@abhinavmathur
Copy link
Owner

Make sure that the cocoon containers have the class "quill_container"
Since the divs are dynamically added, we would need to reinitialize the Quill instances. One way to do this by calling the following in the cocoon:after-insert block

Quilljs.loadDefaults();

One issue that might develop with this method is that it might create a Quill editor container on top of another initialized editor. You might need to destroy and reinitialize those containers every time you insert a new cocoon container.

Pseudo code:

  • Select all the containers (most likely they have a ql-editor class) on after-insert
  • destroy all the containers on after-insert
  • Make sure each container has the class 'quill_container'
  • Reinitialize all containers with Quilljs.loadDefaults();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants