Я застрял на этой проблеме почти 2 дня, рассмотрим следующий код:
«Выбор страны» встречается дважды в форме (ввод), * 1003 *
$('.branch-row').hide();
$('.country-select').change(function(){
console.log($(this));
country_select = $(this);
$.get('get_country_branches.php',
'country=' + $("'#" + country_select.attr('id') + " option:selected'").val() + '&field=' + $(':input:eq('+($(":input").index(country_select) + 1) +')').attr('name'),
function(html){
$(':input:eq('+($(":input").index(country_select) + 1) +')').html(html);
//debug 1
console.log(country_select);
country_select.parent().parent().next().show();
},
'html'
);
}).change();
//debug 2
console.log(country_select);
выходные данные отладки 1 являются одним и тем же объектом:
[выберите # платит-dem.country-выбор]
[Выберите # платит-dem.country-выберите]
однако вывод отладки 2 правильный:
[выберите # Pays-enlev.country-выбор]
[Выберите # платит-dem.country-выберите]
Похоже, проблема заключается в функции $ .get () AJAX и объекте country_select. Есть идеи, что происходит в wtf?