dropdown
加载其中的所有值后,我需要设置一个值。第一个dropdown
(District) 值加载第二个dropdown
(Councils) 的值,并JSon
调用带来ID
选择 Councils 中的值dropdown
,但只能在完全加载后设置:
$("#PostalCode").keyup(function () {
loadPTPostalCode();
});
$("#PostalCodeExtension").keyup(function () {
loadPTPostalCode();
});
function loadPTPostalCode()
{
if ($("#PostalCode").val() >= 1000) {
$.ajax({
url: '/Address/GetPTPostalCode',
type: "POST",
dataType: "json",
data: { postalCode: $("#PostalCode").val(), postalCodeExtension: $("#PostalCodeExtension").val() },
success: function (data) {
//Set the Distict value and fire the load of the Councils Dropdown
$("#districtDropdown").val(data.PTCouncil.PTDistrict.Id).change(function () {
// I tried to define the Council value after the load of his dropdown changes but no luck
$("#councilDropdown").val(data.PTCouncil.Id);
});
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
//alert(textStatus)
}
});
}
}
编辑:
我还有一个与 District Dropdown 相关的级联:
$("#districtDropdown").cascade({
url: "/Address/ListCouncilByDistrict",
paramName: "districtId",
firstOption: 'Selecione o Concelho...',
childSelect: $("#councilDropdown")
});