4

As mentioned in the question we are using JQuery Tagit for our project. We are using ajax search to populate the keywords. The problem we are facing here is that when clicked on the search results with the mouse, it works precisely as described, however, if we use the keyboard navigation to select a result, then the next time the ajax search won't happen for the first keyword press (it only works after second keyword press) To add, the entire process works very much well, if we do the same thing using mouse. I hope I'm clear. Please find the code below:

$('#tags_3').tagit({
    allowSpaces: false,
    placeholderText: 'Search Clients',
    autocomplete: ({
        source: function(request, response) {
            // alert(request.term);
            $.ajax({
                url: '/searchClients',
                data: {
                    format: "json",
                    keywords: request.term
                },
                dataType: 'json',
                type: 'GET',
                success: function(data) {
                    response($.map(data, function(item) {
                        return {
                            label: item.name,
                            value: item.name
                        }
                    }));
                },
                error: function(request, status, error) {
                    alert(error);
                },
                complete: function(request, status, error) {}
            })
        },
    })
});

Edit 1: Problem found on the documentation page too

We just found out that this problem is also on the documentation page. In the first example if you press "a" and then select the value by keyboard, then you won't be able to press "a" again for the next time until some other key is pressed. Hoping that there has to be a solution to this..!

Any help would be really appreciated.

Ajit Hogade
  • 1,072
  • 9
  • 29

1 Answers1

2

So, well, this is a known bug, I guess, already reported on their bugs page here. However, tag-it is kind of very popular and there are many solutions available on similar lines. Few of the other solutions you can look into:

  1. http://webspirited.com/tagit/
  2. https://github.com/Nikku/jquery-tagit

Probably you can look into one of it till the bug is not resolved.

Chintan Parekh
  • 1,101
  • 1
  • 12
  • 31