I have the following structure for the views of a CRUD of categories:
I have javascript libraries in the app view that is in the layouts folder. In all other routes work perfectly. When I enter the category index, the javascript continues to work, but when I enter the category creation it does not work anymore. I realized because I have a drop-down menu that is part of the layout app, which works with javascript and this works well in index but not in the create.
Annex the index code:
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">
Lista de Categorias
<a href="{{ route('categories.create') }}"
class="btn btn-sm btn-primary pull-right">Crear</a>
</div>
<div class="panel-body">
<table class="table table-striped table-hover">
<thead>
<tr>
<th width="10px">ID</th>
<th>NOMBRE</th>
<th colspan="3"> </th>
</tr>
</thead>
<tbody>
@foreach($categories as $category)
<tr>
<td>{{ $category->id }}</td>
<td>{{ $category->name }}</td>
<td width="10px">
<a href="{{ route('categories.show', $category->id) }}" class="btn btn-sm btn-default">ver
</a>
</td>
<td width="10px">
<a href="{{ route('categories.edit', $category->id) }}" class="btn btn-sm btn-default">editar
</a>
</td>
<td width="10px">
{!! Form::open(['route' => ['categories.destroy',
$category->id], 'method' => 'DELETE']) !!}
<button class="btn btn-sm btn-danger">
Eliminar
</button>
{!! Form::close() !!}
</td>
</tr>
@endforeach
</tbody>
</table>
{{ $categories->render() }}
</div>
</div>
</div>
</div>
</div>
@endsection
And of the create:
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">
Crear categoría
</div>
<div class="panel-body">
{!! Form::open(['route' => 'categories.store']) !!}
@include('admin.categories.partials.form')
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
@endsection