jQuery Event Delegation input type keyup blur -
$('#item_code_wrapper').on('keyup blur', '#item_code', function(){ if( $(this).val() != ""){ $.ajax({ url : "../item/code/" + $(this).val(), success: function(data){ if (data.success == 'false') { $('#item_description option').removeattr('selected'); }else{ $('#item_description option:eq(' + data.item_id + ')').attr('selected', true); } } }); } });
this 1 works if copy , paste code. points option item id , remove selected if data success false. again, if manually type item code , has matching id changes option selected doesn't point particular option.
Comments
Post a Comment