mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-09 23:06:08 -06:00
select2 is not a function error fix
This commit is contained in:
parent
fdb1b970f0
commit
0fb0727091
@ -1,33 +1,36 @@
|
|||||||
$( document ).ready(function() {
|
$( document ).ready(function() {
|
||||||
$("select[name='parent_category']").select2({
|
if ($("select[name='parent_category']").length ) {
|
||||||
ajax: {
|
$("select[name='parent_category']").select2({
|
||||||
url: window.location.origin + "/keySearch",
|
ajax: {
|
||||||
type: "GET",
|
url: window.location.origin + "/keySearch",
|
||||||
data: function (params) {
|
type: "GET",
|
||||||
return {
|
data: function (params) {
|
||||||
q: params.term // search term
|
return {
|
||||||
};
|
q: params.term // search term
|
||||||
|
};
|
||||||
|
},
|
||||||
|
processResults: function (data) {
|
||||||
|
return {
|
||||||
|
results: $.map(data.category, function (item) {
|
||||||
|
return {
|
||||||
|
text: item.parents,
|
||||||
|
id: item.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
},
|
||||||
|
cache: true
|
||||||
},
|
},
|
||||||
processResults: function (data) {
|
allowClear: true,
|
||||||
return {
|
theme: "classic",
|
||||||
results: $.map(data.category, function (item) {
|
placeholder:"All" ,
|
||||||
return {
|
minimumInputLength: 3
|
||||||
text: item.parents,
|
});
|
||||||
id: item.id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
};
|
|
||||||
},
|
|
||||||
cache: true
|
|
||||||
},
|
|
||||||
allowClear: true,
|
|
||||||
theme: "classic",
|
|
||||||
placeholder:"All" ,
|
|
||||||
minimumInputLength: 3
|
|
||||||
});
|
|
||||||
|
|
||||||
$("select[name='parent_category']").on('select2:select', function (e) {
|
$("select[name='parent_category']").on('select2:select', function (e) {
|
||||||
var data = e.params.data;
|
var data = e.params.data;
|
||||||
$("input[name='category_name']").val(data.text);
|
$("input[name='category_name']").val(data.text);
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user