Search code examples
jqueryasp.net-mvc-4asp.net-mvc-2summernote

Summernot is not working in MVC4 but working in MVC 2


I want to use summernot in ASP.NET MVC4 application and below is the code which I am using

   @section featured {
 <script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.min.js"></script> 
<link rel="Stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap.min.css"> 
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.0.1/js/bootstrap.min.js"></script> 
<link rel="Stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css">

<link  href="~/summernote.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="~/summernote.js" ></script>


    <script type="text/javascript">
        $(document).ready(function () {
            $('.summernote').summernote();
        });
    </script>


    <div class="summernote">summernote</div>

}

I have used ASP.NET MVC-4 internet application. It is not displaying summernote.

Amazingly, same code is working is ASP.NET MVC 2

is it because ASP.NET MVC 4 include addition bundle which is restricting summernote publish? Below is the console log

enter image description here

Important Note

When I used the same code in ASP.NET MVC4 application "Basic project" it is working fine.

Now, I am sure it is because of additional scripts being added by ASP.NET MVC4 "Internet Project".. Any clue why it is happening?


Solution

  • I have figured it out; it was because of the jquery bundle which was present in the _layout page. Somehow, it was restricting summernote.js

    When I removed script rendering line from the layout, everything went fine.

       @Scripts.Render("~/bundles/jquery")
    

    I believe it can either be done by replacing jquery libraries from script folder with the latest one or to remove all jquery and load it from online reference.