I am using Select2 and seeing the error below. This is my file:
@extends('layouts.app')
<link rel="stylesheet" type="text/css" href="{{URL::asset('css/select2.min.css')}}">
@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">Dashboard</div>
<div class="panel-body">
<select name="primaryLanguage" id="primaryLanguage">
<option value="AL">Alabama</option>
<option value="WY">Wyoming</option>
</select>
</div>
</div>
</div>
</div>
</div>
@endsection
<script type="text/javascript" src="{{URL::asset('js/jquery-1.10.2.js')}}"></script>
<script type="text/javascript" src="{{URL::asset('js/select2.full.min.js')}}"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("primaryLanguage").select2();
});
</script>
The error i keep getting:
home:7 Uncaught TypeError: jQuery(...).select2 is not a function(anonymous function) @ home:7fire @ jquery-1.10.2.js:3101self.fireWith @ jquery-1.10.2.js:3213jQuery.extend.ready @ jquery-1.10.2.js:3425completed @ jquery-1.10.2.js:3455
jquery-1.9.0.js:1 '//@ sourceURL' and '//@ sourceMappingURL' are deprecated, please use '//# sourceURL=' and '//# sourceMappingURL=' instead.
i just faced your own problem, i solved it like this: put these
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="/js/select2.min.js"></script>
in your main layout file (in my case app.blade.php)
then under those scripts put
@yield('scripts')
Then in your blade file where you want to call the plugin, after the
@section('content')
...
@endsection
@section('scripts')
<!-- Here you call the select2 js plugin -->
@endsection
PS : you must put the css file & js file under public folder (public/css & public/js) And here i'm using Laravel Collective for the forms I hope i helped
just remove this code from you main layout
<script src="{{ asset('js/app.js') }}" defer></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With