Setting WYSIWYG Editor Content


Topic: Setting WYSIWYG Editor Content

smachesney pro asked 3 weeks 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 3 weeks 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 pro commented 3 weeks ago

Thanks Grzegorz, is there anyway to do it via jQuery or javascript?


Grzegorz Bujański staff commented 3 weeks 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.


Please insert min. 20 characters.
Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: MDB 5
  • MDB Version: 3.2.0
  • Device: desktop
  • Browser: Chrome
  • OS: windows
  • Provided sample code: No
  • Provided link: No