Topic: Setting WYSIWYG Editor Content
smachesney asked 4 years ago
Hi
I'd like to set the value of the editor on initialization. Right now, in the API, I see there is a method for getCode(), however I don't see one for example setCode().
How would I do this? I tried playing around with append html or setting innerHTML() but neither works. When I was using the old MDB4 jQuery version all I had to do was .val().
Thanks
Grzegorz Bujański staff answered 4 years ago
You just need to add the html you want to add to the WYSIWYG
<div class="wysiwyg" data-mdb-wysiwyg="wysiwyg">
<p>example code</p>
<ul>
<li>example list</li>
<li>example list</li>
</ul>
</div>
smachesney commented 4 years ago
Thanks Grzegorz, is there anyway to do it via jQuery or javascript?
Grzegorz Bujański staff commented 4 years ago
Unfortunately not. There is no special method or way we recommend that you do this with JS/JQ. We recommend doing it as in the example above.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Free
- Premium support: No
- Technology: MDB Standard
- MDB Version: 3.2.0
- Device: desktop
- Browser: Chrome
- OS: windows
- Provided sample code: No
- Provided link: No
klingus pro premium priority commented 3 years ago
I was able to get it working by setting the content into the element with class "wysiwyg-content"
$('.wysiwyg .wysiwyg-content').html('test');