0
최신 select2 버전을 사용하고 있습니다.Select2 get html data attribute
그러나 <select>
html 속성을 얻지 못했습니다.
<select name="category" id="category-select"
data-ajax--search="slug" class="select2 form-control m-b-2" multiple>
</select>
// SCRIPT
const opts = {
ajax: {
url: "/menus/search",
delay: 250,
data: function (param) {
return {q: param.term, page: param.page, category: $(this.element).data('search')};
},
processResults: ({data, total_count}, {page}) => {
page = page || 1;
return {
results: data,
pagination: {
more: (page * 30) < total_count
}
};
},
cache: true
},
scapeMarkup: markup => markup,
templateResult: formatRepo,
templateSelection: formatRepoSelection
};
$('.select2').select2(opts);
나는이 솔루션
How to get data attribute of <select> for use in select2 from inside .select2() ajax call? 여기
https://github.com/select2/select2/issues/3361하지만 여전히 행운을 따랐다.
내 data-ajax--search
항상 return undefined
입니다.
모든 솔루션?