Alex-D / Trumbowyg

A lightweight and amazing WYSIWYG JavaScript editor under 10kB
https://alex-d.github.io/Trumbowyg
MIT License
4.03k stars 615 forks source link

Ajax loaded editor is not refreshing API managed content #1491

Open dermicha56 opened 1 month ago

dermicha56 commented 1 month ago

Description

OS: Windows, MacOS Browser: Chrome

Initially, when typing any content and checking the value with .trumbowyg('html'), it will return the empty string ''

The loaded Trumbowyg editor is not visibly populated by using .trumbowyg('html', '<p>Content</p>') After setting the value with the above command, .trumbowyg('html') returns '<p>Content</p>'

How to reproduce?

Load Trumbowyg form via Ajax -> Manage Content with custom JS function

image

Alex-D commented 1 month ago

Hey I've tried on my side:

$('textarea').trumbowyg();
setTimeout(() => {
    $('textarea').trumbowyg('html', '<h1>Hey</h1>');
}, 1000);

And it works fine :)

Alex-D commented 1 month ago

OK, so it is broken. You're building the editor on something that differs from a textarea element... If you switch from your div to a textarea, it should work