select2 / dropzone
<script type="text/javascript"> Dropzone.autoDiscover = false; $('.dropzone').dropzone({ maxFiles: 1, acceptedFiles: "image/jpeg,image/png,image/gif", success: function(file, response){ $('#inputImg').val(response); } }); var type = $("#type-select"); $.get('/api/type/food/select2', function(m){ type.select2({ data: m.data, }).val([{{ join(',', $food->types->pluck('id')->toArray()) }}]).trigger("change"); }); $('#shop-select').select2({ ajax: { url: '/api/shops/select2', delay: 250, data: function (params) { return { q: params.term, // search term }; }, processResults: function (data, params) { return { results: data.data }; }, cache: true } }); </script>