Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing local data? #250

Closed
Siyfion opened this issue May 20, 2013 · 6 comments
Closed

Changing local data? #250

Siyfion opened this issue May 20, 2013 · 6 comments

Comments

@Siyfion
Copy link

Siyfion commented May 20, 2013

Does typeahead.js support changing of the local data array post-initialization while still getting the typeahead functionality for the newly inserted items?

I just tried to utilize this in my AngularJS app:

      $scope.addCountry = function () {
        $scope.exampleData.local.push({name:'XXX Test Place', code: 'XXX'});
      };

      // single dataset
      $scope.exampleData = {
        name: 'countries',
        valueKey: 'name',
        local: [
          {name: 'Afghanistan', code: 'AF'},
          {name: 'Åland Islands', code: 'AX'},
          {name: 'Albania', code: 'AL'},
          {name: 'Algeria', code: 'DZ'},
          {name: 'American Samoa', code: 'AS'},
          ...
       ]
     };
@jharding
Copy link
Contributor

There's currently not a way to add local data post-initialization. What you'd have to do is destroy the typeahead and reinitialize it.

@Siyfion
Copy link
Author

Siyfion commented May 22, 2013

@jharding Now that is a shame!

But I guess it's not a massively common use-case, so perhaps it's not that awkward to destroy & re-init.

@brianmhunt
Copy link

@Siyfion you could try the compute argument per pull request #220 - does that do what you want?

@jharding
Copy link
Contributor

jharding commented Feb 2, 2014

In v0.10, if you are using a bloodhound suggestion engine, you can accomplish this by using Bloodhound#add.

@jharding jharding closed this as completed Feb 2, 2014
@Siyfion
Copy link
Author

Siyfion commented Feb 12, 2014

@jharding is there a way to remove an existing entry in a similar vein?

@jharding
Copy link
Contributor

Not yet, but there's an issue opened to add a way, see #652.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants