Reputation: 622
I am just updating stuff to Laravel 8 from 7 and I am trying something simple.
My /layouts/app file is
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ asset('siteimages/favicon.ico') }}">
<title>Daddies Control</title>
<!-- Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap">
<!-- Styles -->
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script>
@yield('morehead')
</head>
<body class="font-sans antialiased">
<div class="min-h-screen bg-gray-100">
@include('layouts.navigation')
<!-- Page Heading -->
<header class="bg-white shadow">
<div class="mx-auto py-6 px-4 sm:px-6 lg:px-8">
@yield('header')
</div>
</header>
<!-- Page Content -->
<main>
@yield('content')
</main>
</div>
@yield('morescripts')
</body>
</html>
my test dashboard file is:
@extends('layouts.app')
@section('morehead')
<link rel="stylesheet" href="{{ asset('css/stt.css') }}">
@endsection
@section('header')
dashboard
@endsection
@section('content')
some content
@endsection
@section('morescripts')
<hr/>
a script
@endsection
The section 'morescripts' is being ignored completely. I use this to add specific datascript (such as datatables).
Upvotes: 0
Views: 1914
Reputation: 60
if you are including written js code at morescripts section then your code should be like
<script>
@yeild('morescripts')
</script>
and if you want add script links the you should add like below
@section('morescripts')
<script src= "https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js" />
@endsection
for specifically datatables you can use
@section('morescripts')
<script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>
<script type="text/javascript">
// your inline script
$(document).ready(function() {
$('#example').DataTable();
});
</script>
@endsection
if this didn't work
try by replacing @endsection
by @stop
Upvotes: 1