vendredi 27 septembre 2019

How to implement select2 in laravel

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()
            });
        </script>

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)

NOTE: in console network both js and CSS for select2 are loaded

What is wrong with my code?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire