Topic: Cannot get data from mdbWYSIWYG plugin or customize the functionality of the upload image button
Ruben Chevez pro asked 6 years ago
*Expected behavior*I expected to be able to edit the content from inside the which the mdbWYSIWYG plugin works using jquery $("#textarea-container").html(content) or $("#textarea-container").val(content) . Also, the image button only allows to include link to images, I expected to be able to upload images.
*Actual behavior*Cannot get/set data from/to mdbWYSIWYG plugin using jquery or customize the functionality of the upload image button. I need to upload data when clicking the image button.
Resources (screenshots, code snippets, etc.)$("#post_description").mdbWYSIWYG();
The following code snippets do not work.
$("#textarea-container").html(description);
let content = $("#container").html();
$("#textarea-container").val(description);
let content = $("#container").val();
Bartłomiej Malanowski staff pro premium answered 6 years ago
Hi, @Ruben Chevez!
I've just initialized my WYSIWYG like this:
$("#demo").mdbWYSIWYG();
And then, I was able to get its content:
$('#demo').val();
Everything looks like it works fine. What's the issue you're facing?
About the image upload, currently, it's not possible. I hope this will be added soon
Otto commented 4 years ago
Can you please show us how to set the content in both views visual and code.
Krzysztof Wilk staff answered 4 years ago
Hi!
You can set WYSIWYG content before initializing it using JS. Your code should look like this:
$('#demo').val('Example')
$("#demo").mdbWYSIWYG();
Of course, you can set it using HTML too, just put your HTML code between <textarea></textarea>
tags.
You can check effects here: https://mdbootstrap.com/snippets/jquery/krzysztof-wilk/2362676#html-tab-view
But for now, I'm afraid you can't set content after initializing a WYSIWYG Editor, you have to do it before.
Best regards
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.8.0
- Device: Desktop
- Browser: Chrome
- OS: Windows
- Provided sample code: No
- Provided link: No