V
V
Vladislav Dovgun2018-03-16 16:12:16
JavaScript
Vladislav Dovgun, 2018-03-16 16:12:16

data-* attributes in select2?

There is a code:

$('.itemName').select2({
    placeholder: 'Введите перенесенные болезни, можно вводить название или код МКБ',
        ajax: {
            url: "{{route('getRequestmkb10')}}",
            dataType: 'json',
            delay: 250,
            processResults: function (data) {
                return {
                    results: $.map(data, function (item) {
                        return {
                            text: item.value+' :: '+item.text,
                            id: item.id,
                            title: item.value,
                            disease: item.text
                        }
                        // alert(item.id);
                    })
                };
            },
            cache: true
        }
    });

And the select itself:
<select id="cn_ds" class="itemName form-control" style="width:100%;" name="f_sickness[]" value="{{old('f_sickness')}}" multiple data-ajax--disease=""></select>


I want to add an arbitrary data-disease attribute. But no matter how I tried, nothing worked. Off. quite a few examples are devoted to this issue in the documentation.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question