触发器无效,状态值未从状态下拉列表中自动选择。我有form和onchange事件填写列表信息到国家,州..等形式。默认状态为隐藏字段,并在国家/地区字段中进行更改时填充。 customField是表单字段jr_country,jr_state..etc
select: function( event, ui ) {
self._relatedListing_select(ui);
}
_relatedListing_select: function (ui) {
for (customField in ui.item) {
if (customField == 'value' || customField == 'label') continue;
if (ui.item[customField] == null || ui.item[customField] == '' || ui.item[customField] == 'undefined') continue;
try{
var fieldObject = jQuery('#jr-form-listing').find('.'+customField);
if(fieldObject.is('input')){
var fieldType = fieldObject.attr('type');
switch (fieldType) {
// radio buttons
case 'radio':
jQuery(fieldObject.selector + '[value=' + ui.item[customField].replace(/\*/g,'') + ']').click();
break;
// text and other types
default:
fieldObject.val(ui.item[customField]);
break;
}
} else if(fieldObject.is('select')) {
jQuery(fieldObject.selector + ' option[value=' + ui.item[customField].replace(/\*/g,'') + ']').attr('selected', 'selected');
}
fieldObject.trigger('change');
} catch(err){
//alert(customField); // show error field name
}
}
}
}