Answer the question
In order to leave comments, you need to log in
django-select2 how to use with three tables?
There is a form for adding a characteristic, in it you need to make two dependent fields Characteristic and Value, the list in the Value field should change depending on the selected Characteristic, how to implement this correctly using django-select2 and the table structure attached below
Answer the question
In order to leave comments, you need to log in
When changing the value in the CHARACTERISTIC field, send an ajax request to select valid values and throw the response into values
$.ajax({
method: 'post',
data: data,
type: 'json',
success: function (responce) {
var data = [{id: '', text: helpText, disabled: true, selected: true}];
if (responce.data) {
responce.data.map(function (el) {
data.push(el);
});
$('#ЗНАЧЕНИЕ').select2('destroy').empty().select2({data: data});
}
},
error: function (e) {
console.log(e);
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question