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

Duplicate Data or Partial Duplicate Data with Typeahead.JS #223

Open
cait08 opened this issue Sep 2, 2014 · 1 comment
Open

Duplicate Data or Partial Duplicate Data with Typeahead.JS #223

cait08 opened this issue Sep 2, 2014 · 1 comment

Comments

@cait08
Copy link

cait08 commented Sep 2, 2014

To replicate this issue, use tagmanager with typeahead.js, with autoselect set to true. Essentially, when you hit 'enter' it does two things: Typeahead pushes the autoselected tag, AND tagmanager pushes the incompletely entered tag.

//===========================
//Tags Management
//===========================

jQuery(".tm-input").tagsManager({
      prefilled: false,
      CapitalizeFirstLetter: true,
      preventSubmitOnEnter: true, // deprecated
      isClearInputOnEsc: true, // deprecated
      delimiters: [9, 13, 44], // tab, enter, comma
      backspace: [8],
      maxTags: 10,
      output: '#taglist',
      replace: true,
      deleteTagsOnBackspace: true, // deprecated
      tagCloseIcon: '<span class="glyphicon glyphicon-remove"></span>',
      tagClass: 'tm-tag tm-tag-info',
      tagsContainer: '#tagsContainer',
      onlyTagList: false,
      fillInputOnTagRemove: true
});


//===========================
//Typeahead.js
//===========================


var tagApi = $("#addtags").tagsManager();       

var addtags = new Bloodhound({
    datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d['tag']); },
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    dupChecker:true,
//  remote: '/tags/tags/search.json?q=%QUERY',
    prefetch: {url: '/tags/tags/search.json?q='}
});

addtags.initialize();

$('#addtags').typeahead({
    hint:true,
    highlight:true,
    autoselect:true,
    dupChecker:true,
    },
{
    displayKey: 'tag',
    source: addtags.ttAdapter(),
}).on('typeahead:selected', onTagSelect);

function onTagSelect($e, datum) {
    $('#addtags').val('');
    tagApi.tagsManager("pushTag", datum['tag']);
    console.log("new tag from typeahead.js: " + datum['tag'] );
    };
@drauch
Copy link

drauch commented Oct 29, 2016

Same problem as #204 , unfortuntely, no solution yet :(

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

2 participants