this is my route
Route::get('/', 'SpielplanController@getSpielplan');
this is my app layout page
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dateneingabe</title>
<link rel="stylesheet" href="/css/app.css">
<script src="{{asset('/js/jquery-3.2.1.min.js')}}"></script>
</head>
<body>
@yield('contentSpiel')
@yield('A')
</body>
</html>
Now here is my @yield('contentSpiel')
@extends('app')
@section('contentSpiel')
<div class="form-group">
<label for="">Spiele</label>
<select class="form-control input-sm" name="spiele" id="spiele">
@foreach($alleSpiele as $alleSpieleOutput)
<option value="{!! $alleSpieleOutput->heimmannschaft !!}">{{$alleSpieleOutput->heimmannschaft}}</option>
@endforeach
</select>
</div>
<script>
$('#spiele').on('change', function(e){
console.log(e);
var spielID = e.target.value;
//ajax
$.get('/spieler-table?spielID=' + spielID, function(data){
//success data
console.log(data);
});
});
</script>
@endsection
and here is my section A
@extends('app')
@section('A')
<h2>asd</h2>
@endsection
I can not understand why I get only the section @yield('contentSpiel') back in my browser. What I have to change that both @yields are in my browser?
you can load only one view from your controller. now if you have one view but you want to yield multiple portions of it then u can try this example :
@extends('layouts.app')
@section('contentSpiel')
<div class="form-group">
<label for="">Spiele</label>
<select class="form-control input-sm" name="spiele" id="spiele">
@foreach($alleSpiele as $alleSpieleOutput) <option value="{!! $alleSpieleOutput->heimmannschaft !!}">$alleSpieleOutput->heimmannschaft}}</option>
@endforeach
</select>
</div>
<script>
$('#spiele').on('change', function(e){
console.log(e);
var spielID = e.target.value;
//ajax
$.get('/spieler-table?spielID=' + spielID, function(data){
//success data
console.log(data);
});
});
</script>
@endsection
@section('A')
<h2>asd</h2>
@endsection
now if you will print your value in one view and want to load another view like sider bar in your master then just include it.
this is my app layout page
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dateneingabe</title>
<link rel="stylesheet" href="/css/app.css">
<script src="{{asset('/js/jquery-3.2.1.min.js')}}"></script>
</head>
<body>
@yield('contentSpiel')
@include('your_view_file_path')
</body>
</html>
in layout :
<body>
@yield('contentSpiel')
@yield('A')
</body>
@stack('scripts')
contecontentSpiel.blade.php view (this view should be returned in action)
@extends('app')
@section('contentSpiel')
<div class="form-group">
...
</div>
@endsection
@push('scripts')
<script>
$('#spiele').on('change', function(e){
...
});
</script>
@endpush
@section('A')
...
@endsection
if you want to have several blade files... you can create sectionAForContentSpiel.blade.php and move here section A code
@section('A')
...
@endsection
and then in contecontentSpiel.blade.php
@include('sectionAForContentSpiel')
PS: using @stack('scripts')
and @push('scripts') - @endpush
you can include scripts in the bottom of the page.
I think you need to change your app layout page like:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dateneingabe</title>
<link rel="stylesheet" href="/css/app.css">
<script src="{{asset('/js/jquery-3.2.1.min.js')}}"></script>
</head>
<body>
<section class="contentSpiel">
@yield('contentSpiel')
</section>
<section class="A">
@yield('A')
</section>
</body>
</html>
Hope this help for you !!!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.