CutCodeDown

Web Development => JavaScript => Topic started by: durango_d on 1 Nov 2020, 07:52:13 pm

Title: Tracking Elements by unique internal userside identifier
Post by: durango_d on 1 Nov 2020, 07:52:13 pm
Hi,

Does js (or users side) maintain an internal identifier for the element...   For example if i have 3 divs with all the same id, does the user side have an internal identifier to know one from the other.  I cant assign another id i have to use the js as is to identify the element.

I am thinking that somewhere inside the  nodes, there has to be something.

if so:

What is it called?

Do i have access to that identifier?

Does the identifier change with a fresh page?  If not, can i rely on that identifier for storage and retrieval?

If not is there a way to assign a token value to the element for storage, without using id or class?

Thanks..
Title: Re: Tracking Elements by unique internal userside identifier
Post by: GrumpyYoungMan on 2 Nov 2020, 02:26:17 am
My very limited knowledge says that all HTML ID’s have to be unique?
Title: Re: Tracking Elements by unique internal userside identifier
Post by: durango_d on 2 Nov 2020, 04:14:02 am
yes true.... i was hoping for some kind of like 64 bit identifier internally or the like, there must be something because i have 6 divs with the same id's and the users side seems to know the difference between them. 

for now what i did was gave span inside the target a unique id, then used the parentNode to pull that (1 of 6) id...  not sure how it knows which is which without that id.. but it does.....
Title: Re: Tracking Elements by unique internal userside identifier
Post by: Jason Knight on 2 Nov 2020, 11:52:58 am
because i have 6 divs with the same id's and the users side seems to know the difference between them. 
That's not a thing, and it means your code is broken gibberish nonsense.

ID's can only be used once on a page. Do not re-use them and anyone telling you otherwise needs a quadruple helping of sierra tango foxtrot uniform. They're talking out their arse.
Title: Re: Tracking Elements by unique internal userside identifier
Post by: durango_d on 3 Nov 2020, 07:14:25 am
The problem is that this is now the log and the garage work and it does work.   All of them have the same id starting from the chat code part but a different h3 title and different content.   But somehow the system knows the difference.

This is how its set up, i thought i was following your code, ill have to look again.   The problem is that we cant have them different or we will have to call the iife function using a id value, i dont think that will work.  Look at my last code i posted on that topic, thats how it is now, and its working.

So how does the users side know the difference?  There has to be some kind of identifier inside the Nodes somewhere.
Title: Re: Tracking Elements by unique internal userside identifier
Post by: durango_d on 3 Nov 2020, 07:33:07 am
here is the lot.childNodes list  they are all  id="databox" class="databox"

Quote
NodeList(37) 
[text, comment, text, div#databox.databox, text, comment,
text, comment, text, div#databox.databox, text, comment,
text, comment, text, div#databox.databox, text, comment,
text, comment, text, div#databox.databox, text, comment,
text, comment, text, div#databox.databox, text, comment,
text, comment, text, div#databox.databox, text, comment, text]


Title: Re: Tracking Elements by unique internal userside identifier
Post by: Jason Knight on 3 Nov 2020, 10:25:33 am
Why did you add id's in the first place? The park/unpark code I wrote DOESN'T USE ID'S in the first place for each and every blasted sub-child.

Multiple instances of the same ID is gibberish nonsense, The code I provided doesn't care about ID's so that should work, but anything that actually uses ID's won't.

WHY? WHy are you adding the same ID to everything?!? What nonsensical trash are you doing where that would/should even BE a thing?
Title: Re: Tracking Elements by unique internal userside identifier
Post by: durango_d on 3 Nov 2020, 03:01:43 pm
I know, i didnt have the id's before, but adding the DND (drag n drop) i had to have someplace to put the draggable attribute to true, where else would i put it, and they all have to be grouped, it left me no choice.

It does work surprisingly, the only bug is that it does not always go back to the same spot as you can see in the video.   

Could i assign the resizable via the iife we already have?  or maybe a separate iife? and then i can remove the id's   

Also remember that i will need to identify each block somehow so i can save its location for users.
Title: Re: Tracking Elements by unique internal userside identifier
Post by: Jason Knight on 4 Nov 2020, 08:32:00 am
I know, i didnt have the id's before, but adding the DND (drag n drop) i had to have someplace to put the draggable attribute to true, where else would i put it, and they all have to be grouped, it left me no choice.
The what now? That doesn't make any sense. What the blazes does the draggable attribute have to do with it having an ID?

And yes, if you're just setting draggable to true, do it in the existing loop if it's on the same elements and/or parents/siblings of same.
Title: Re: Tracking Elements by unique internal userside identifier
Post by: durango_d on 4 Nov 2020, 09:04:28 am
OH my bad, i thought assigning draggle requried an id, i did not know it could be done on just a naked div... mmm interesting...  yes i will try assigning to via the js loop then i can save some code too... :)    thanks