Всплывающая форма после выбора города, не обновляет whS. Если закрыть и открыть модалку данные появляються
Подозрение что whS.empty().trigger("chosen:updated"); не срабатывает.
сам один из селектов
<div class="warenhouseSelect">
<p>Выберите отделение для доставки</p>
<select name="warenhouseSelect" id="warenhouseSelect2" data-placeholder="Выберите отделение" style="width:350px;"></select>
</div>
JS
openNP: function() {
$.fancybox({
padding: 20,
wrapCSS: 'npPopup',
content: $('#novaPoshtaPopup').clone(true, true),
helpers: {overlay: {locked: false}},
beforeShow: function() {
var c = $(this.content), cityS = c.find('select[name="citySelect"]'),
whS = c.find('select[name="warenhouseSelect"]');
console.log('1');
console.log(whS);
c.find('select').chosen({
allow_single_deselect: true
});
console.log('2');
cityS.on('change', function() {
var value = $(this).find('option:selected').val();
console.log('3');
console.log(value);
if (value == 0) {
console.log('4');
whS.empty().trigger("chosen:updated");
return false;
}
$.post('/include/ajax/', {
uri: location.pathname,
form: $.param({
action: 'np/warenhouse',
sessid: window.ss,
city: value
})
}, function(data) {
if(data.action) {
console.log('5');
whS.empty().html(data.select).trigger("chosen:updated");
}
console.log('6');
console.log(data.select);
}, 'json');
});
c.find('.novaPoshta__submit').on('click', function() {
var city = cityS.find('option:selected').text(), wh = whS.find('option:selected').text();
if(!!city && !!wh) {
$('#ORDER_PROP_27').val(city + ' ' + wh);
$.fancybox.close();
}
delete city; delete wh;
});
return false;
}
});
},