I'm trying to create an array that displays the replies to a blog post in uneditable quill boxes. However, when I'm trying to grab the data from my html code, the setContent isn't working. I did some console logging, and found that the data is being retrieved correctly, a stringified JSON object. I also tried setting the content to other values, a raw JSON object, and that works perfectly. What's going wrong here?
var data = document.querySelectorAll(".answers .answer data");
var answerQuill;
for(let i=0; i<data.length; i++){
answerQuill = new Quill('#disp'+i.toString(), {
modules: {toolbar: false},
theme: 'snow'
});
answerQuill.setContents(JSON.parse(data[i].value), 'api');
answerQuill.enable(false);
};```
Update: I got it working, but I don't understand my solution lol. Apparently I had to parse this twice?? Not sure why, but it works now. Huh.
let parsed = JSON.parse(data[i].value);
answerQuill.setContents(JSON.parse(parsed.answer), 'api');
answerQuill.enable(false);