max-favilli / tagmanager

A jQuery plugin (working nicely with twitter bootstrap)
Mozilla Public License 2.0
770 stars 236 forks source link

Tagmanager + typeahead, hint persists when tag not in autocomplete added #204

Open shaunith opened 10 years ago

shaunith commented 10 years ago

When adding a tag which has autocomplete results the tag-manager-hints persist.

Example: I want to add a tag that does not exist, such as the country 'Au' rather than Austria. I enter 'Au' and then enter or tab and the following occurs.

screen shot 2014-03-25 at 9 40 49 pm

screen shot 2014-03-25 at 9 41 22 pm

echochristopher commented 10 years ago

A very similar problem that is messing me up is the following:

  1. Go to tagmanager+typeahead
  2. Type something and press enter
  3. Click away The text that you just submitted repopulates the text field
Noamyoungerm commented 10 years ago

@echochristopher, you can fix this by adding

$('.tm-input').keydown(function(e) {
    if ((e.which == 13 || e.which == 9)) { 
        $('.tm-input').typeahead('val', "");
    }
});

to your code. When typeahead is present, jQuery's .val() doesn't work to clear the field.

drauch commented 8 years ago

I just ran into the same problem. I added:

    .on('typeahead:autocomplete typeahead:selected', function(e, d){
        tagsManager.tagsManager('pushTag', d);
        songTags.typeahead('val', '');
    });

Unfortuantely, you cannot use it in combination with delimiters:[9] (which adds the hint and the autocompleted value to the tags). My current workaround is to call tagsManager.tagsManager('popTag', songTags.typeahead('val')); in the autocomplete/selected handler above, but this is also not what I really want.

It would be really great if there would be some kind "either autocomplete or delimiter has been called" event.