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

remote filter processing indicator / disable certain elements in data array #425

Open
jpgilchrist opened this issue Aug 16, 2016 · 0 comments

Comments

@jpgilchrist
Copy link

I had a need to display a "loading" or "processing" indicator while my remoteFilter was doing work. I came up with a solution which goes something like this:

{
  ...
  remoteFilter: _.debounce(function(query, callback) {
    if (typeof query === 'string' && query.length < 2)
      return;

    callback([{display: "<li style='text-align: center;'><i class='fa fa-spinner fa-spin'></i></li>", name: query}]);

    $.ajax({...})
      .done(function (results) {
        callback(_.map(results, function(result) {
          var doc = $.extend({}, result);
          // some logic to determine doc.display
          return doc;
        }
      });
  }, 150), 
  displayTpl: '${display}',
  ...
}

As you can see I call callback twice; once with some dummy data and once with real data. The dummy data is simply something that will display font awesome's spinner icon.

First, it would be cool if the project had a built in feature for this.

Secondly, my problem arises because I am doing this work around and there's a possibility for a user to hit tab, enter or click the spinner icon before the second callback is executed. Therefore, a user could select bad data. My quick fix for this is to set hightlightFirst: false so that they can't just hit tab or enter immediately to select it, which brings up my second suggestion: have an attribute on an element disable in order to mark an element in a list as non-selectable.

Thoughts, opinions, suggestions, alternatives solutions are all welcomed and appreciated!

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

No branches or pull requests

1 participant