$data = ['results' => $results, 'pagination' => ['more' => false]];
$hash = hash('sha256', print_r($data, true));
$name = $hash . '.json';
- $dir = \Cubist\Util\Files\Files::mkdir(public_path('select2'));
+ $dir = \Cubist\Util\Files\Files::mkdir(storage_path('select2'));
$file = $dir . '/' . $name;
if (!file_exists($file)) {
file_put_contents($file, json_encode($data));
}
- $this->setAttribute('ajax', $name);
+ $this->setAttribute('ajax', $hash);
}
}
if (input.length === 0) {
input = form.find('[name="' + form.data('bmid') + '___' + varname + '"]');
- console.log(input);
}
var res = $(input).val();
style="width: 100%"
@include('crud::fields.inc.attributes', ['default_class' => 'form-control select2_from_array'])
@if (isset($field['allows_multiple']) && $field['allows_multiple']==true)multiple @endif
- @if(isset($field['ajax']) && $field['ajax']) data-ajax="{{$field['ajax']}}" @endif
+ @if($ajax) data-ajax="{{$field['ajax']}}" @endif
>
@if (isset($field['allows_null']) && $field['allows_null']==true)
@if($is_null)
var options = {
theme: "bootstrap"
};
- if ($(this).is(['data-ajax'])) {
- options.ajax = {url: $(this).data('ajax'), dataType: 'json'};
+ console.log($(this));
+ if ($(this).is('[data-ajax]')) {
+ options.ajax = {
+ url: '{{backpack_url('select2')}}' +'/'+ $(this).data('ajax'),
+ dataType: 'json'
+ };
}
if (!$(obj).hasClass("select2-hidden-accessible")) {
+ console.log(options);
$(obj).select2(options);
}
});