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.

3310 posts
  • Provided great contribution to our forums
  • Nominated Community Superstar of the month
  • Helps us moderate the forums
  • Has been part of the Envato Community for over 5 years
+18 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

47 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

3310 posts
  • Provided great contribution to our forums
  • Nominated Community Superstar of the month
  • Helps us moderate the forums
  • Has been part of the Envato Community for over 5 years
+18 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());
} );
47 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

47 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

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by