JQUERY : UI.ComboBox Change event


JQuery.Ui.ComboBox Events:

// Fill combo

$(document).ready(function () {

FillCounties();
function FillCounties() {
var url = “/Default/AsyncCounties”;
$.getJSON(url, null, function (data) {
$(‘#_county’).empty();
$.each(data, function (index, optionData) {
$(‘#_county’).append(“<option value='”
+ optionData.Value
+ “‘>” + optionData.Text
+ “</option>”);
});
});

};

// Change event: on change of county, fill courthouse

$(“#_county”).combobox({
selected: function (event, ui) {
var countyId = “”;
countyId = $(‘#_county’).val();
$(‘#_court’).empty();
var url = “/default/AsyncCourthouses?countyId=” + countyId;
$.getJSON(url, null, function (data) {
$(‘#_court’).empty();
$(‘#_court’).append(“<option SELECTED value=’ALL’>ALL COURTHOUSES</option>”);
$.each(data, function (index, optionData) {
$(‘#_court’).append(“<option value='”
+ optionData.CodeValue
+ “‘>” + optionData.CodeText
+ “</option>”);
if (optionData.CodeValue != “”) $(‘#_court’).removeAttr(“disabled”);
else $(‘#_court’).attr(“disabled”, true);
});
});
}
});

 

});

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s