user12151390
user12151390

Reputation:

How to retrieve data from database and able to edit in summernote editor?

I'm facing a problem and i couldn't find a solution to solve it. My problem is that i have apply a plugin which called as ( Wysiwyg - summernote editor into my Laravel framework project ) . Everything works fine but when i click on the edit page, the data is unable to retrieve from the database and directly edit with the editor function. Can anyone familiar with this help me out ? Thank you so much

As you can see my placeholder is the value retrieve from the database, i just wondering why i couldn't put the data into the editor function and directly edit from it

<div class="form-group">


 <label for="company_policy_policy_details">Please Enter Policy Details<span<p><font color="#F05340"> *</font></p></label></span>

                <input type="text" name="policy_details" id="abc"  class="form-control" value="{!!$policy->policy_details!!}" cols="139" rows="10">
                </textarea>
            </div>



            <div id="summernote"></div>

            <script>

                $('#abc').summernote({
                    placeholder:value="{!!$policy->policy_details!!}",
                    tabsize: 2,
                    height: 100
                });
            </script>
            </body>
            </html>
            </div>`

Expected output = i want the value in placeholder are able to show inside the editor and able to edit it directly , Thankssssss

After update , but not the expected output i want

Upvotes: 2

Views: 5103

Answers (2)

Abd Abughazaleh
Abd Abughazaleh

Reputation: 5545

If you want to write html code and add it to editor you can use pasteHTML , to Paste HTML string.

pasteHTML

// @param {String} HTML string
var HTMLstring = '<div><p>Hello, world</p><p>Summernote can insert HTML string</p></div>';
$('#summernote').summernote('pasteHTML', HTMLstring)

Code

If you want to get data from database use the below code :

$('#summernote').summernote('code', {{$data->content}});

Upvotes: 0

Andy Song
Andy Song

Reputation: 4684

I believe this code will show the data from your db.

$('#summernote').summernote({
    placeholder: "{!!$policy->policy_details!!}",
    tabsize: 2,
    height: 100
}).summernote('code', `{!!$policy->policy_details!!}`);

Upvotes: 3

Related Questions