Skip to content

Commit

Permalink
Fixed duplicate tags in autoCompleteTags Array
Browse files Browse the repository at this point in the history
  • Loading branch information
Ranjit Singh committed Aug 5, 2018
1 parent a732ebf commit a56b81c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,25 +376,30 @@ function loadAutoCompleteTags(context,field,data)
availableTags=[];
for(let i=0;i<data.length;i++)
{
let filterTag = data[i].replace(/\,+\s+$|\,+$/,'');
let filterTag = data[i].replace(/\,+\s+$|\,+$/,'').trim();
let filterTagArr = filterTag.split(",");
if(filterTagArr.length>0)
{
for (let j = 0; j < filterTagArr.length; j++) {
if(availableTags.indexOf(filterTagArr[j])==-1)
let multipleTag = filterTagArr[j].trim();
if(availableTags.indexOf(multipleTag)===-1)
{
availableTags.push(filterTagArr[j]);
availableTags.push(multipleTag);
}
}
}
else
{
availableTags.push(filterTag);

if(availableTags.indexOf(filterTag)===-1) {
availableTags.push(filterTag);
}
}

}

console.log(availableTags);

function split(val) {

return val.split(/;\s*/);
Expand Down

0 comments on commit a56b81c

Please sign in to comment.