I have three drops that cascade. Zone → Region → Territory
I am using Bootstrap popups.
When I select Drop Zone, the corresponding areas should be connected and at the same time the territories of the newly connected regions should be connected with the drop-down territory.
Here is my dropdown initialization code.
$('#ddlZone').multiselect({
enableClickableOptGroups: true,
enableCollapsibleOptGroups: true,
enableFiltering: true,
includeSelectAllOption: true,
nonSelectedText: 'Select Zone',
enableCaseInsensitiveFiltering: true,
selectAllNumber: true,
onChange: function(option, checked,select) {
FillRegionsDropdown();
FillTerritoriesDropdown();
}
Here is the code for the above functions.
function FillRegionsDropdown()
{
var Zone=$('#ddlZone').val();
if(Zone != null)
{
Zone= Zone.join(",");
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "@Url.Action("BindRegionsOnZonesAjax", "GeoMap")",
data: "{ZoneIds:'" + Zone + "'}",
success: function (Result)
{
$("#ddlRegion").html("");
$('#ddlRegion').multiselect( 'refresh' );
$.each(Result, function (key, value) {
$("#ddlRegion").append($("<option></option>").val(value.Value).html(value.Text));
});
$('#ddlRegion').multiselect( 'rebuild' );
$("#ddlRegion").multiselect('selectAll', false);
$("#ddlRegion").multiselect('updateButtonText');
}
});
}
}
The above code works fine, that is, in the Zone drop-down menus, the areas that bind and set to select all change.
But the problem is that the Binding area is reset by lowering the zone.
And here is the code for the Territory drop-down lists.
function FillTerritoriesDropdown()
{
var rgns=$('#ddlRegion').val();
if(rgns != null)
{
rgns= rgns.join(",");
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "@Url.Action("BindTerritoriesOnRegionsAjax", "GeoMap")",
data: "{RegionIds:'" + rgns + "'}",
success: function (Result)
{
$("#ddlTerritory").html("");
$('#ddlTerritory').multiselect( 'refresh' );
$.each(Result, function (key, value) {
$("#ddlTerritory").append($("<option></option>").val(value.Value).html(value.Text));
});
$('#ddlTerritory').multiselect( 'rebuild' );
$("#ddlTerritory").multiselect('selectAll', false);
$("#ddlTerritory").multiselect('updateButtonText');
}
});
}
}
It $('#ddlRegion').val()does not update to the values of recently linked areas that are caused by a change of zone.
$('#ddlRegion').val() .
6 .
- ?