Could you post the whole layouts and an example of a child ?
Jun 19, 2018
19
Level 2
How to extend javascript from master layout to child layout ?
The Default layouts.app.blade.php has
<script src="{{ asset('js/app.js') }}" defer></script>
I want to use this in child blades. But its not working. When is use
@extends('layouts.app')
in child blade .
But when I use HTML in the child as well i am able to use it
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<script src="{{ asset('js/app.js') }}" defer></script>
</head>
So how to use javascript in child blade?
Level 50
your problem was with id app-4 you added it inside child template instead of parent. try this
@extends('layouts.app')
@section('content')
<div>
<ol>
<li v-for="todo in todos">
<h4> @{{ todo.text }}</h2>
</li>
</ol>
</div>
@endsection
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Scripts -->
<!-- Fonts -->
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css?family=Raleway:300,400,600" rel="stylesheet" type="text/css">
<!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
<script src="{{ asset('js/app.js') }}"></script>
</head>
<body>
<div id="app-4">
<nav class="navbar navbar-expand-md navbar-light navbar-laravel">
<div class="container">
<a class="navbar-brand" href="{{ url('/') }}">
{{ config('app.name', 'Laravel') }}
<main class="py-4">
@yield('content')
</main>
</div>
</body>
</html>
1 like
Please or to participate in this conversation.