Topic: How to get the content from the MDBWysiwyg Vue component?
stevecjor priority asked 10 months ago
This is regarding:
I would expect to be able to specify the component as:
<MDBWysiwyg v-model=content />
so that I could get the current content from the text editor after the user has modified it.
MDBWysiwyg has the content as a slot. Therefore, the parent component does not see any changes to the text in the slot. In order to see the content, you have to do something like:
document.getElementsByClassName('wysiwyg-content'). Making assumptions about what's going on in the child component is a bad practice and fragile as the application code will break if this changes. Therefore, I think it should be provided as a v-model.
Resources (screenshots, code snippets etc.)
There is a
getCode method (described in the API tab), which returns the HTML code.
Here's an example:
<template> <MDBWysiwyg ref="wysiwygRef" /> </template>
then somewhere in
script part get the code:
const wysiwyg = ref(wysiwygRef); let code = ""; ... code = wysiwyg.value.getCode(); // after or inside mounted hook or in any custom method
Keep coding, Mikołaj from MDB
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
- User: Priority
- Premium support: Yes
- Technology: MDB Vue
- MDB Version: MDB5 1.8.0
- Device: laptop
- Browser: Chrome
- OS: MacOS Monterey 12.0.1
- Provided sample code: Yes
- Provided link: No