- Grew a moustache for the Envato Movember competition
- Community Moderator
- Contributed a Blog Post
- Author was Featured
- Item was Featured
- Won a Competition
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Has been a member for 4-5 years
can you just try change() as well?
function update_user_type(inputbox){
$(".adburb").html($(inputbox).val());
return false;
}
$("#suburb").keyup(function(){ update_user_type(this); }).change(function(){ update_user_type(this); });
if jquery autocomplete fires the change then that’ll work. if that doesn’t work then you’ll have to hunt through the autocomplete code to see if there is a callback function that is run after selecting an item
autocomplete has a “select” callback function:
http://api.jqueryui.com/autocomplete/#event-selectHmm.. looks like I am gonna have to hunt thru jquery ui lol ( oh fun )
Cheers Dave
designchemical said
autocomplete has a “select” callback function: http://api.jqueryui.com/autocomplete/#event-select
I am not sure how to test that, beyond my capability. Will play tho, thankyou
- Grew a moustache for the Envato Movember competition
- Community Moderator
- Contributed a Blog Post
- Author was Featured
- Item was Featured
- Won a Competition
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Has been a member for 4-5 years
designchemical said
autocomplete has a “select” callback function: http://api.jqueryui.com/autocomplete/#event-select
perfect!
so leave your original code and wack this in somewhere:
$( "#suburb" ).on( "autocompleteselect", function( event, ui ) {
$(".adburb").html($("#suburb").val());
} );
Using “close” may be better since this will fire after the menu closes and the value updated (I presume):
$("#suburb").autocomplete({
close: function(event, ui) {
$(".adburb").html($("#suburb").val());
}
});
Edit: Sorry, didnt see the previous reply.
So I created a fiddle. ( based off someone elses code )
And replicated the issue we have: http://jsfiddle.net/qb59C/45/
update: working http://jsfiddle.net/qb59C/46/
PERFECT
Cheers Guys xxxxxxx
Or just change the original autocomplete function to:
$(function () {
$("#suburb").autocomplete({
source: ['England', 'Germany', 'Denmark', 'Sweden', 'France', 'Greece', 'Italy'],
change: function (event, ui) {
if (!ui.item) {
this.value = '';
}
},
close: function(event, ui) {
$(".adburb").html($("#suburb").val());
}
});
});
The code is actually a tad more complex than my example, essentially, we retrieve ( via json ) from our db, suburb postcode and state.
So now to figure out how to propagate the bloody state and postcode, but will get there.
Cheers Guys ( its only for a poxy form, and only becuase we want to display a clients ad preview lol )
But UI is kind of an anal passion of mine

You will be rewarded with virtually anything you ask for.