sgruhier/typeahead-addresspicker

Support latest typeahead

Closed this issue · 16 comments

Love your picker, but it seems to only works with typeahead 0.10.x and not 0.11.x, unfortunately

Correct
I checked 0.11.x and the change A LOT the Bloodhound API :(
I need to check doc (and code!) of this new version.

Any help is welcome ! :)

From the Changelog

0.11.0 April 25, 2015

An overhaul of typeahead.js – consider this a release candidate for v1. There are bunch of API changes with this release so don't expect backwards compatibility with previous versions. There are also many new undocumented features that have been introduced. Documentation for those features will be added before v1 ships.

Beware that since this release is pretty much a rewrite, there are bound to be some bugs. To be safe, you should consider this release beta software and throughly test your integration of it before using it in production environments. This caveat only applies to this release as subsequent releases will address any issues that come up.

+1

GREAT plugin but we really need support for 0.11.x

@sgruhier any idea when you add support for latest typeahead? It would greatly improve this package.

I don't think it would take more than a few hours to build.

I'm pretty busy these days
unfortunately, I cannot give you an estimated date :(

Any success on that? Would be much appreciated

I managed find a way to get the addresspicker to work with the latest typeahead and bloodhound (0.11.1). It's a bit hacky, but saved my day.

The 'get' function of bloodhound has changed and we need to use 'search' instead. So in the addresspicker file replace

AddressPicker.prototype.get = function(query, cb) {

with

AddressPicker.prototype.search = function(query, sync, async) {

and in the that function replace

return cb(predictions);

with

return async(predictions);

One problem remains. The async callback is only called, if a remote option is specified for the bloodhound base class. So when instantiating the address picker just add a fake remote option.

var addressPicker = new AddressPicker({
   remote: 'fakeRemote'
});

any chance you guys know how to change the address format in both the suggestions and the results? I would like to remove the country and add the postal_code. I already restricted suggestions to US only.

please make it work for lastest version, a lot of things have changed in 0.11 typehead.

Addresspicker doesn't even fires up.

It would be really great if you can support latest version of typeahead, there's a lot of issues with backward compatibility.

Thank you @Zumpo !!! It works!

@Zumpo I've trying to fix it with your code (change the .get function in AddressPicker file).
Geocoding works very well but the addresspicker never shows up the autocomplete suggestion in the typeahead dropdown menu (?!)

Sample of my own code:

addressPickerObject = new AddressPicker({
     remote: 'fakeRemote'
 });


   // add the custom addressPicker event to the form
  addressPickerObject.bindDefaultTypeaheadEvent($(config.addressPickerDiv));


 $(config.addressPickerDiv).typeahead(null,{
      displayKey: 'description',
      source: addressPickerObject//.ttAdapter()
});

Any ideas ?

@sgruhier Sébastien, please take a look at this update when you have time, this extension is very helpful, but it doesn't work with the latest versions of dependencies.

Thanks

Sorry I was so busy
I'll try to give a look today or before the end of that week

I puhsed a typeahead-0.11.1 branch
You'll have to add a limit options

    $('#address1').typeahead(null, {
      displayKey: 'description',
      limit: 20,
      source: addressPicker
    });

I don't know exactly why. I'll try to figure it out.
I'm not happy also when you type the selection panel blinks (quick hide and show) If someone has an idea :)

Any feedback are welcome.

I'm guessing something to do with

that._append(query, suggestions.slice(0, that.limit - rendered));

Which is on line 1724 of the typeahead-bundle.js file.

Excellent work on this. Just outstanding. Thanks so much for your efforts.

Yes, I don't understand yet that part of the code 'that.limit - rendered'