Marshall Wu
Marshall Wu

Reputation: 11

How can we apply Quill to all class selector (not just the 1st match)

Recently I met a problem in terms of Quill usage to Class selectors. Generally, my intention is to apply Quill to all div which has a class name. However, it turns on it only apply to the 1st matched element.

For example, this script below will only turn 1st matched element with class "basic-editor" into Quill editor.

var basicEditor = new Quill('.basic-editor');

Any suggestion on that?

Upvotes: 1

Views: 1250

Answers (2)

Florent Giraud
Florent Giraud

Reputation: 225

Hello if you do this at the begining you can find some performance issue. I am working on it because i have to use this editor in multiple context. I think the best way is to destroy create it not just all create like you want to do

Upvotes: 0

jhchen
jhchen

Reputation: 14767

Quill takes a selector or a DOM element so you can just loop with something like this:

let containers = document.querySelectorAll('.basic-editor');
let editors = Array.from(containers).map(function(container) {
  return new Quill(container);
});

Upvotes: 3

Related Questions