Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

Option to complete tags programmaticaly #29

Closed
KrisBraun opened this issue Nov 29, 2013 · 5 comments
Closed

Option to complete tags programmaticaly #29

KrisBraun opened this issue Nov 29, 2013 · 5 comments

Comments

@KrisBraun
Copy link

Great project! Helped us remove jQuery.

We're seeing users type a tag (email addresses in our case) and then click 'Send' without typing comma or enter to complete the tag. Is there a way we can read any text in progress, or force tag completion?

@mbenford
Copy link
Owner

Hi Kris. Glad to know it's being useful to you. :)

That's the expected behavior given the current implementation, but definitely not the correct one, as you have pointed out. I believe there could be an option to add the current tag when the input field loses focus. What do you think?

If you happen to have another suggestion, please let me know.

Kind regards.

@KrisBraun
Copy link
Author

That's exactly what I just hacked in, adding this to the link function of the tagsInput directive:

        input.bind('blur', function(e) {
          if (scope.tryAdd()) {
            scope.$apply();
          }
        });

@mbenford
Copy link
Owner

mbenford commented Dec 1, 2013

It turns out that doing that when the input loses focus solves one problem and creates a new one at the same time. When the autocomplete list is visible, the user can select a suggestion by clicking on it, and that triggers the input's blur event, which in turn adds the current text instead of the selected suggestion.

I'll have to figure out how to solve that. I welcome suggestions. :)

@KrisBraun
Copy link
Author

Ah, right. I didn't notice it because I've defined my regex for valid email addresses, so the partial value was just discarded.

@mbenford
Copy link
Owner

mbenford commented Dec 3, 2013

I think I got a working solution. Will try to add it to version 1.0.

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

No branches or pull requests

2 participants