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

AJAX call #33

Closed
mhoude opened this issue Jun 25, 2014 · 2 comments
Closed

AJAX call #33

mhoude opened this issue Jun 25, 2014 · 2 comments
Labels

Comments

@mhoude
Copy link

mhoude commented Jun 25, 2014

I have a case where I may have thousands of possible options and I want to avoid having to retrieve all the possible options from my API before we can use the dropdown.

Is there a way to retrieve the list dynamically using asynchronous ajax calls to return the options based on a minimum character input from the user ?
Basically, this feature is available on the "select2" plugin using the "ajax" or "query" parameters (http://ivaynberg.github.io/select2/). I was using this plugin which is awesome but doesn't have any checkbox multi-select feature. I'm looking into using yours but this is the only thing where I'm afraid I'll get stuck having problems.

@isteven
Copy link
Owner

isteven commented Jun 25, 2014

Hi @mhoude ,

Unfortunately the current version does not support data population using AJAX.

I have this feature in mind but probably will only implement it on the next releases.

@isteven
Copy link
Owner

isteven commented Jun 25, 2014

On a second thought, this hack is not pretty but might work:

In your controller:

  1. Prepare an empty array variable for the input model, say $scope.inputModel
  2. Not necessary, but you can set a simple flag, say $scope.gotData = false;

In your view:

  1. Create a text box for your search input. Put an event listener or on-change here, calling an AJAX function to populate the $scope.inputModel as the user types something. If there's data, set $scope.gotData to true. If not, set to false.
  2. Create an instance of this multi-select directive (you can remove the filter element if you want to), but disable it until the AJAX call from number (1) returns something (or after the input model is populated). You can use is-disabled="!gotData" attribute to do this.

@isteven isteven closed this as completed Jun 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants