Thursday, 3 October 2013

Trigger is not working and value not auto selected

Trigger is not working and value not auto selected

Trigger is not working and state value not auto selected from state drop
down. I have form and onchange event fill listing information into
country,state..etc in that form. state is by default hidden field and
populate upon change in country field. customField are form field
jr_country, jr_state..etc
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
}
}
}

No comments:

Post a Comment