Files
php_task_1/assets/js/custom_select2.js
T
2022-06-30 05:46:02 -04:00

92 lines
2.1 KiB
JavaScript
Executable File

document.addEventListener('DOMContentLoaded', function()
{
var ajaxURLPath = document.location.origin + '/';
$(".get_schools_select2").select2({
minimumInputLength: 1,
ajax: {
url: ajaxURLPath + 'v1/api/schools',
dataType: 'json',
type: "POST",
quietMillis: 50,
minimumResultsForSearch: 50,
data: function (term)
{
return term;
},
results: function (data)
{
return { results: data };
}
}
});
$(".get_professors_select2").select2({
minimumInputLength: 1,
ajax: {
url: ajaxURLPath + 'v1/api/professors',
dataType: 'json',
type: "GET",
quietMillis: 50,
minimumResultsForSearch: 50,
data: function (term)
{
return term;
},
results: function (data)
{
return { results: data };
}
}
});
$(".get_courses_select2").select2({
minimumInputLength: 1,
ajax: {
url: ajaxURLPath + 'v1/api/courses',
dataType: 'json',
type: "GET",
quietMillis: 50,
minimumResultsForSearch: 50,
data: function (term)
{
return term;
},
results: function (data)
{
return { results: data };
}
}
});
$(".get_textbooks_select2").select2({
minimumInputLength: 1,
ajax: {
url: ajaxURLPath + 'v1/api/textbooks',
dataType: 'json',
type: "GET",
quietMillis: 50,
minimumResultsForSearch: 50,
data: function (term)
{
return term;
},
results: function (data)
{
return { results: data };
}
}
});
}, false)