I'm trying to run a jquery code that shows an enlarged model when clicked. I tested it using a raw html/css/js program and it works well. However, when trying to put it onto my laravel program, it looks like my blade file isn't picking up on the jquery code. I placed the js code in my public/js/external.js file. Here's my script code that I placed at the end of my blade code:
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script src="public/js/external.js"></script>
Can anyone tell me what's the problem? I will be happy to provide more information.
CodePudding user response:
See how your blade has @yield('content')
You will want to add one in the footer for scripts such as @yield('scripts')
- Thats in your base blade.
example:
<html>
<head>
<title>App Name - @yield('title')</title>
</head>
<body>
<div >
@yield('content')
</div>
<script src="your main app script here.">
@yield('scripts')
</body>
</html>
Then in your view you can do
@section('content')
your page content.
@endsection
@section('scripts')
<script>
// your jQuery here.
</script>
@endsection
CodePudding user response:
Go to the view source page and check the scripts are there and linked properly.
Master blade:
<html>
<head>
<title>Title</title>
</head>
<body>
<div >
@yield('content')
</div>
@stack('script')
</body>
Child blade:
@section('content')
your page content.
@endsection
@push('script')
your both scripts
@push
CodePudding user response:
Be sure that your jquery link is the first js you included, ordering is so important while including your assets.