5492 posts
  • 5 Years of Membership
  • Affiliate Level 1
  • Australia
  • Author Level 3
+5 more
Australia
says

I asked the question on Stack

Weirdly no replies, so either I have stumbled across cutting edge technology, I asked a stupid question or all the jQuery guys are watching 2 and 1/2 men !

Any ideas, on a fix for this issue plz. :) You will be rewarded with virtually anything you ask for.

5441 posts
  • Author Level 11
  • Moderator
  • Winner
  • 6 Years of Membership
+20 more
dtbaker
Moderator
says

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

50 posts
  • Affiliate Level 7
  • Author Level 9
  • Collector Level 1
  • Top Monthly Author
+7 more
designchemical
says

autocomplete has a “select” callback function:

http://api.jqueryui.com/autocomplete/#event-select
5492 posts
  • 5 Years of Membership
  • Affiliate Level 1
  • Australia
  • Author Level 3
+5 more
Australia
says

Hmm.. looks like I am gonna have to hunt thru jquery ui lol ( oh fun )

Cheers Dave

5492 posts
  • 5 Years of Membership
  • Affiliate Level 1
  • Australia
  • Author Level 3
+5 more
Australia
says

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

5441 posts
  • Author Level 11
  • Moderator
  • Winner
  • 6 Years of Membership
+20 more
dtbaker
Moderator
says

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());
} );
50 posts
  • Affiliate Level 7
  • Author Level 9
  • Collector Level 1
  • Top Monthly Author
+7 more
designchemical
says

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.

5492 posts
  • 5 Years of Membership
  • Affiliate Level 1
  • Australia
  • Author Level 3
+5 more
Australia
says

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

50 posts
  • Affiliate Level 7
  • Author Level 9
  • Collector Level 1
  • Top Monthly Author
+7 more
designchemical
says

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());
        }
    });
});
5492 posts
  • 5 Years of Membership
  • Affiliate Level 1
  • Australia
  • Author Level 3
+5 more
Australia
says

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

by
by
by
by
by
by