0

I am using summernote rich text editor, and I want to edit my posted data(stored in DB). I am sending the value to the text area and inputs but not showing into the text area and showing into the input. kindly share some solutions and suggestions with me. any jquery and js function like this... here is rendered data to web page

 route.get('/edit/:id', async (req, res) =>{ const id = req.params.id const article = await Article.findById(id) res.render('editarticle',{article:article}) }) 

and here is ejs or HTML

<%- include('header'); -%> <div class="container-9"> <h2>Create Article Here</h2> <hr> <form action="/create/blog" method='post'> <input type="text" name="title" id="" placeholder="Enter Title" value='<%=article.title%>'/> <input type="text" name="description" id="dics" placeholder="Enter Description" value='<%=article.discription%>'/> <hr> <button id='btn-post' type="submit">Post</button> <textarea name='content' id="body" rows="10" value="<%=article.content%>" ></textarea> </form> </div> <%- include('footer'); -%> 

3 Answers 3

2

I have solved this problem with help of one line of code. I have got the solution after 2 month

 var value = $('#value').val() console.log(value); $('textarea#body').summernote('pasteHTML', value); 

if want to render the HTML for edit this will work, var value = $('#value').val() it just receiving the value (HTML) from the backend and $('textarea#body').summernote('pasteHTML', value); this line of code pesting the HTML into summernote editor.

Sign up to request clarification or add additional context in comments.

4 Comments

Hello @Tushar do you know how can I disable the click outside from the summernote dialogs? I want to make the 'X' the only option to close the modal hehe
Hi @Sophie, could you share some images of your summernote dialogs. What do you want to do
Hey Tushar, thank you so much for your time, I did it hehe I was trying to disable the outside click from dialog created by extended plugin.
@Sophie, good to hear. Keep it up .....
0

@tushar Very useful !!

I use it on summer note as like

Put Content in a div, and set it display none

<div id="contentDumpDiv" style="display:none;"> <?php echo $post['content'] ?> </div> 

then use this javascript code

var value = $('#contentDumpDiv').html(); $('textarea#saContent').summernote('pasteHTML', value); 

Comments

-1

pasteHTML will make duplicates on each call, use:

var value = $('#contentDumpDiv').html(); $('textarea#contentDumpDiv').summernote('code', value); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.