ContentTools
ContentTools copied to clipboard
The same id attribute can be assigned to multiple html elements.
Hi,
Title explains well I think. CT allows the following to happen within the document.
Content Tool should check if an id has been used already on an element and ask the user to choose a different id.
@turigeza it does not matter if CT allows it. It can be useful in situations to fire off some sort of plugin that is used in multiple spots.
I also think it is the users concern to use one or more of the same id's.
Sure no prob if you wanted it that way :). I thought I mention it because I came across with it as I was looking at how it's implemented.
id's meant to be unique I think btw ... but I presume you know that already :) http://stackoverflow.com/questions/9454645/does-id-have-to-be-unique-in-the-whole-page
I would recommend that we flag to the user that the Id isn't unique, but not require it to be unique.
For me it would be a slight usability issue not to allow the user to set it to a duplicate value as it would require you to first edit the other Id to set this one (which would be annoying), so instead we can just flag to the user that it isn't unique, and assume that if they're setting an Id they know enough to decide if that's a problem or not.
@turigeza - hope you don't mind but I've re-opened the issue (as per my comment above). I'd always recommend leaving an issue open for a little while to give multiple user's chance to weigh in on an issue :smile:
:) Why would I mind for sure ... I didn't allow duplicate id's when I used Content Edit. Just because I would never want duplicate ids and I never thought one would. After all that is what classes are for in some way ...
So I warn users and offer them to scroll and highlight the element with the same id. They can then decide what to do. Change the old element or the new but they can not have the same id on the same page.
This is quite a work thought because from this onwards you have to think of id clashes when ever you are duplicating content or bringing in content from other pages, custom html name it ....
Keep in mind the use of ids by users is pretty much limited to anchor links.
And now that I wrote all this down realising maybe it's not even worth the hassle to do all these check ... :)
@turigeza True I know it is meant to be unique, but also some people use it in a not unique way. That is why I commented with my comment hope you don't mind.