Search code examples
laravel-5summernote

Linking Css and Js Files Summernote assets in Laravel 5 The proper way


I am creating a blog with a Summernote editor.My problem is the editor does not display properly in blog text area.

enter image description here

I use partials to created forms and the js and css files were linked this way

<div class="form-group" id="summernote">
  {!! Form::label('body', 'Body') !!}
  {!! Form::textarea('body', null, ['class' => 'form-control']) !!}
</div>

<div class="form-group">
  {!! Form::submit($submitButtonText,['class' => 'btn btn-primary']) !!}
</div>

<script>
  $(document).ready(function() {
   $('#summernote').summernote();
  });
</script>

master layout

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title></title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <link rel="stylesheet" type="text/css" href="../css/summernote.css"> 
 </head>
<body>
 @include('partials.nav')
<main>
  <div class="container">
    @include('flash::message')

   @yield('content')
  </div>
</main>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>

<script>
 /*$('div.alert').not('.alert-important').delay(3000).slideUp(300);*/
   $('#flash-overlay-modal').modal();
</script>
<script src="../js/summernote.js"></script>

  @yield('footer')
</body>
</html>

How do you link and use Summernote in Laravel?This is my 1st week in Laravel, and I am trying to learn by creating a simple blog with Twitter Bootstrap


Solution

  • It should be:

    <link rel="stylesheet" type="text/css" href="<?= asset('css/summernote.css') ?>">
    

    Same principle for js.