Issue
I have simple input I would like to user select js select2js
Here is my input
<div class="form-group">
<select class="js-example-basic-multiple form-control" name="states[]" multiple="multiple">
<option value="AL">Alabama</option>
...
<option value="WY">Wyoming</option>
</select>
<!-- Button trigger modal -->
</div>
in my app.blade.php (master)
I have this
$(document).ready(function() {
$('.js-example-basic-multiple').select2()
});
Now when I run my app I get this error
caught TypeError: $(...).select2 is not a function
at HTMLDocument.<anonymous> (create:420)
at j (jquery.min.js:1197)
at k (jquery.min.js:1203)
In console network both js and CSS for select2 are loaded
What is wrong with my code?
Solution
May be due to one of the following reason:
- Your select2 JS is not added in right place, like you need to add it after jQuery
- Other JS scripts might have throwing an error which causing all other JS scripts to breaks
- Your jQuery version is not compatible with the select2 jQuery plugin
- You may have multiple jQuery added for different jQuery plugin
Answered By - Azhar Rasheed
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.