5492 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Located in Australia
  • Has sold $1,000+ on Envato Market
+4 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.

3180 posts
  • Helps us moderate the forums
  • Has been part of the Envato Community for over 5 years
  • Helped several times protecting Envato Market against copyright violations
  • Won a competition
+15 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

46 posts
  • Has referred 1000+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
designchemical says

autocomplete has a “select” callback function:

http://api.jqueryui.com/autocomplete/#event-select
5492 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Located in Australia
  • Has sold $1,000+ on Envato Market
+4 more
Australia says

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

Cheers Dave

5492 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Located in Australia
  • Has sold $1,000+ on Envato Market
+4 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

3180 posts
  • Helps us moderate the forums
  • Has been part of the Envato Community for over 5 years
  • Helped several times protecting Envato Market against copyright violations
  • Won a competition
+15 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());
} );
46 posts
  • Has referred 1000+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 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
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Located in Australia
  • Has sold $1,000+ on Envato Market
+4 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

46 posts
  • Has referred 1000+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 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
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Located in Australia
  • Has sold $1,000+ on Envato Market
+4 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