Я использую плагин Jquery Select Box на моем сайте. Параметры в элементе get обновляются с помощью ajax, поэтому, когда вы выбираете что-то в 1 окне, появляются опции для следующего поля.FireBug - TypeError: item undefined
Я почти получил его работу, но когда я нажму на второй вариант коробки, варианты третьего варианта не появятся. Я получаю сообщение об ошибке в FireBug говоря:
TypeError: элемент не определен
item.selected = истина;
Он говорит, что находится в js-файле Chosen Box.
JS =======================
Chosen.prototype.result_select = function(evt) {
var high, high_id, item, position;
if (this.result_highlight) {
high = this.result_highlight;
high_id = high.attr("id");
this.result_clear_highlight();
if (this.is_multiple) {
this.result_deactivate(high);
} else {
this.search_results.find(".result-selected").removeClass("result-selected");
this.result_single_selected = high;
this.selected_item.removeClass("chzn-default");
}
high.addClass("result-selected");
position = high_id.substr(high_id.lastIndexOf("_") + 1);
item = this.results_data[position];
item.selected = true; <---------- Error
this.form_field.options[item.options_index].selected = true;
if (this.is_multiple) {
this.choice_build(item);
} else {
this.selected_item.find("span").first().text(item.text);
if (this.allow_single_deselect) this.single_deselect_control_build();
}
if (!(evt.metaKey && this.is_multiple)) this.results_hide();
this.search_field.val("");
if (this.is_multiple || this.form_field_jq.val() !== this.current_value) {
this.form_field_jq.trigger("change", {
'selected': this.form_field.options[item.options_index].value
});
}
this.current_value = this.form_field_jq.val();
return this.search_field_scale();
}
};
Я провел часы, пытаясь понять это, но не могу. Любая помощь будет оценена по достоинству.
Вы уверены, что 'results_data' не пуст? Если это так, имеет ли оно значение в результате 'high_id.substr (high_id.lastIndexOf (" _ ") + 1)'? – Oded
@BenjaminGruenbaum Я просто что-то пробовал. –
@Oded Я надеюсь, что это не похоже на немой вопрос, но как я могу проверить, пуст ли он или нет. Потому что я думаю, что на момент загрузки страницы, но не позже –