@push('before_scripts')
<form style="visibility: hidden;" method="post" id="{!! $id !!}" enctype="multipart/form-data"
action="{{$field['action']}}">
+ @csrf
<input type="file" @if($field['multiple'])name="file[]" multiple="multiple" @else name="file" @endif />
</form>
@endpush
<script>
$(function () {
$('{!! $field['trigger'] !!}').on('click', function () {
- $("#{!! $id !!}").find('input').get(0).click();
+ $("#{!! $id !!}").find('input[type="file"]').get(0).click();
return false;
});
$("#{!! $id !!} input").on('change', function () {
- $("#{!! $id !!}").submit();
- })
+ var form = $("#{!! $id !!}");
+ var f = $(form).ajaxSubmit({dataType: 'json'});
+ var xhr = f.data('jqxhr');
+ xhr.done(function (data) {
+ console.log(data);
+ });
+ });
});
</script>
@endpush