Francisunoxx Francisunoxx - 1 month ago 9
PHP Question

Bootstrap Dropdown won't work even script it's already imported

I wanted to make a drop down menu on Laravel but unfortunately it won't work the

bootstrap.min.js
or
bootstrap.js
but other javascript file works perfectly. Can somebody tell me which part I'm wrong?

Folder structure:

SC

header - Navigation bar

<nav class = "navbar navbar-default" role = "navigation">

<div class = "collapse navbar-collapse">

<ul class = "nav navbar-nav navbar-right">
@if (Auth::check())

<li class = "dropdown">
<a href = "#" class = "dropdown-toggle" data-toggle = "dropdown" role = "button"
aria-haspopup = "true" aria-expanded = "false"> Documents<span class = "caret"></span></a>

<ul class = "dropdown-menu">
<li><a href = "">Create Documents</a></li>
</ul>
</li>

@else
<li><a href = "{{ route('auth.login') }}"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>


@endif
</ul>

</div>




Template

<!doctype html>
<html>
<head>
<title>@yield('title')</title>
<link rel = "stylesheet" href= "{{ URL::asset('css/bootstrap.min.css')}}">
<link rel = "stylesheet" href = "{{ URL::asset('css/select2.min.css') }}">

<script type = "text/javascript" src = "{{ URL::asset('js/bootstrap.js') }}"></script>
<script type = "text/javascript" src = "{{ URL::asset('js/jquery.js') }}"></script>
<script type = "text/javascript" src = "{{ URL::asset('src/js/tinymce/js/tinymce/tinymce.min.js') }}"></script>
<script type = "text/javascript" src = "{{ URL::asset('js/select2.min.js') }}"></script>
</head>

</html>

Answer

replace

<script type = "text/javascript" src = "{{ URL::asset('js/bootstrap.js') }}"></script>
<script type = "text/javascript" src = "{{ URL::asset('js/jquery.js') }}"></script>

with

<script type = "text/javascript" src = "{{ URL::asset('js/jquery.js') }}"></script>
<script type = "text/javascript" src = "{{ URL::asset('js/bootstrap.js') }}"></script>

as far i know jquery file have to be loaded before bootstrap js file