我做了一些更新,比如添加 $(document).ready() 处理程序等。
var arrayOfCountries = [{"name":"USA","id":1,"active":"Y"},{"name":"CANADA","id":2,"active":"Y"},{"name":"AALAND ISLANDS","id":270,"active":"Y"},{"name":"AFGHANISTAN","id":236,"active":"Y"},{"name":"ALBANIA","id":109,"active":"Y"},{"name":"ALGERIA","id":17,"active":"Y"},{"name":"AMERICAN SAMOA","id":307,"active":"Y"},{"name":"AMMAN","id":111,"active":"Y"},{"name":"ANDORRA","id":112,"active":"Y"},{"name":"ANGOLA","id":54,"active":"Y"},{"name":"ANGUILLA","id":22,"active":"Y"},{"name":"ANTARTICA","id":308,"active":"Y"},{"name":"ANTIGUA","id":113,"active":"Y"}];
$(document).ready(function(){
if ( $('#countrySelection').find('option').length == 0 ){
$.loadingMessage = "Retrieving Countries";
$.showPageLoadingMsg();
$.each(arrayOfCountries, function() {
$('#countrySelection').append('<option value="' + this.id + '">' + this.name + '</option>');//.selectmenu('refresh');
});
$.mobile.hidePageLoadingMsg();
}
});