1
Could someone explain to me why the class multipleSelect() of jQuery does not update the values received via JSON?
For example, when I select a state, in my other selection field, the related cities of that state are filtered. When I Linko the jQuery in the field of cities, the field is only blank, that is, it only receives the value of when the page is loaded, which in the case is blank.
I want to know how I recover the state and play the cities filtered dynamically, and where I connect to my field cities?
$('select[name=uf]').on('change', function () {
var uf = $(this).val();
$.get('/judicial/get-cidades/' + uf, function (busca) {
$('select[id=comarca_id]').empty();
$('select[id=comarca_id]').append('<option value=""> </option>');
$.each(busca, function (key, value) {
$('select[id=comarca_id]').append('<option value=' + value.name + '>' + value.name + '</option>');
});
});
});
$(document).ready(function(){
$('select[name=comarca_id]').multiselect({
numberDisplayed: 0,
includeSelectAllOption: true,
allSelectedText: 'Todos',
nonSelectedText: 'Selecione',
nSelectedText: 'Selecionado',
selectAllText: 'Todos',
});
});
Here is the link from where I got this jQuery.
Put the code in so people can take a look...
– JuniorNunes
I put js where I connect jquery to the city field
– Luiz Gustavo Costa Ceolin
You have tried running $('select[name=comarca_id]'). multiselect({... again after you have finished filling select?
– JuniorNunes
First I play the cities filtered by the state in select and then I run multiselect(). I put in on my question now how I play the dice in select tbm..
– Luiz Gustavo Costa Ceolin