Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

why does the id of tags change to tags14985314860880 #345

Open
chengbaobao630 opened this issue Jun 27, 2017 · 4 comments
Open

why does the id of tags change to tags14985314860880 #345

chengbaobao630 opened this issue Jun 27, 2017 · 4 comments

Comments

@chengbaobao630
Copy link

why does the id of tags change to tags14985314860880;
i user function load() to show the view ;
when i change to another view and then back,the id of tags change to tags14985314860880;
$("#tags").addTag(tag) it doesn't work

@XLCYun
Copy link

XLCYun commented Feb 26, 2018

Hi, I have run into this problem as well. The appending number seem like something generating by Date according by the time you initializing this control. So I tracked to these code:

var id = $(this).attr('id');
if (!id || delimiter[$(this).attr('id')]) {
  id = $(this).attr('id', 'tags' + new Date().getTime() + (uniqueIdCounter++)).attr('id');
}

It is from line 209-212.
I think the basic thought in here is if we did not assign an ID for the input control( which we have ), tagsInput will assign one for it. But the if statement does not just check if there is an ID, it will assign one for it when it doesn't have an ID or it has an ID but it also have a delimiter.
In my case, I have assigned an ID and a delimiter for my input control, so it will assign another ID to replace my own ID, which should be a bug.
It seems no one is maintaining this repo?

@XLCYun
Copy link

XLCYun commented Feb 26, 2018

The BUG in here is the object delimiter will exist in the whole session, it is use to store the delimiter of all tag input controls, and index by the ID of them.

So the first time, we create an input control (call it A) with an ID '#tag' and delimiter ';'. It work just fine.
Then I destroy it, and create it (call it B) again, its ID become something like tags14985314860880.
Because in the object delimiter, the delimiter of A has not been clean, still remain in it. so when we create B,
javascript if (!id || delimiter[$(this).attr('id')])
This would be true.

I delete the second condition 'delimiter[$(this).attr('id')', and it works for me. I still don't know the meaning of this second condition. My best guess is if there are two input control with one single ID, it will assigned another ID for the second input control, but it doesn't seem like a good gesture to deal with those bad design(ID should be unique!).

@sovicheacheth
Copy link

The BUG in here is the object delimiter will exist in the whole session, it is use to store the delimiter of all tag input controls, and index by the ID of them.

So the first time, we create an input control (call it A) with an ID '#tag' and delimiter ';'. It work just fine.
Then I destroy it, and create it (call it B) again, its ID become something like tags14985314860880.
Because in the object delimiter, the delimiter of A has not been clean, still remain in it. so when we create B,
javascript if (!id || delimiter[$(this).attr('id')])
This would be true.

I delete the second condition 'delimiter[$(this).attr('id')', and it works for me. I still don't know the meaning of this second condition. My best guess is if there are two input control with one single ID, it will assigned another ID for the second input control, but it doesn't seem like a good gesture to deal with those bad design(ID should be unique!).

Removed delimiter[$(this).attr('id') did solve the issue. Thanks.

@rockandruby
Copy link

rockandruby commented May 22, 2019

@lucknerjb So is that the only solution to patch plugin source code?

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

No branches or pull requests

4 participants