Wednesday, April 18, 2012

change() fires only when losing focus

I currently using the change function from jQuery. The change event is only fired when i click outside the textfield. So when i insert a text in my textbox nothing is happening but when i lose the focus on the textfield the event fires.
No i want to fire the event without having to click outside the textfield.



this is my code:



 jQuery("#customfield_10000").change(function(){
crmAccount = jQuery(this).val();
alert(crmAccount);
lijstAccounts = [];

jQuery.ajax({
url: "http://localhost/papa/jQuery/development-bundle/demos/autocomplete/searchAccounts.php?jsonp_callback=?",
dataType: 'jsonp',
jsonp: "jsonp_callback",
data: {
featureClass: "P",
style: "full",
maxRows: 12,
name_startsWith: jQuery(this).val()
},
success: function( data ) {
jQuery.map( data, function( item ) {
lijstAccounts.push(item.label);
jQuery('#customfield_10000').trigger(
'setSuggestions',
{ result : textext.itemManager().filter(lijstAccounts, query) }
);
return {
label: item.label,
value: item.value
}
});
}
});

});




No comments:

Post a Comment