Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Edit.cshtml

        <div class="form-group">
        @Html.LabelFor(model => model.long_Description, htmlAttributes: new { @class = "control-label col-md-4" })
        <div id="summernote"></div>
        <div class="col-md-10">
            @Html.TextAreaFor(model => model.long_Description, new { @id = "long_Description", @style = "display:none;", @class = "form-control" })
            @Html.ValidationMessageFor(model => model.long_Description, "", new { @class = "text-danger" })
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#summernote').summernote(
                {
                    tabsize: 2,
                    height: 150
                });

            var editor = $('#long_Description').html();

            $('#summernote').html(editor);

            $('#editorbtn').hover(function () {

                var editor = $('.note-editable').html();
                $('#long_Description').html(editor);

            });

        });

    </script>
Create.cshtml

<div class="form-group">
        @Html.LabelFor(model => model.long_Description, htmlAttributes: new { @class = "control-label col-md-4" })
        <div id="summernote"></div>
        <div class="col-md-10">
            @Html.TextAreaFor(model => model.long_Description, new { @id = "long_Description", @style = "display:none;", @class = "form-control" })
            @Html.ValidationMessageFor(model => model.long_Description, "", new { @class = "text-danger" })
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#summernote').summernote(
                {
                    tabsize: 2,
                    height: 150
                });

            var editor = $('#long_Description').html();

            $('#summernote').html(editor);

            $('#editorbtn').hover(function () {

                var editor = $('.note-editable').html();
                $('#long_Description').html(editor);

            });

        });

    </script>

    <input type="submit" value="Add" id="editorbtn" class="btn btn-primary" />


What I have tried:

I added SummerNote to the project. But I have a problem. The SummerNote is empty when you press the product edit key. How can I fix ? Would you make an illustrative example? English is not good I hope you understand. Thank you.
Posted
Updated 10-Jan-18 6:15am

1 solution

Getting started : get & set code[^]
JavaScript
$('#summernote').summernote({
    tabsize: 2,
    height: 150
});

var description = $('#long_Description').val();
$('#summernote').summernote('code', description);


It may be simpler to just turn the original input element into the editor, rather than using a div:
<div class="form-group">
    @Html.LabelFor(model => model.long_Description, htmlAttributes: new { @class = "control-label col-md-4" })
    <div class="col-md-10">
        @Html.TextAreaFor(model => model.long_Description, new { @class = "form-control" })
        @Html.ValidationMessageFor(model => model.long_Description, "", new { @class = "text-danger" })
    </div>
</div>

<script>
$(function(){
    $("#long_Description").summernote({
        tabsize: 2,
        height: 150
    });
});
</script>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900