DataTables / FixedHeader

Fix the header, footer, left or right columns of a table in place, to always show them when scrolling
http://www.datatables.net/
Other
75 stars 83 forks source link

Clonning header duplicates elements `id`s #88

Closed kmmbvnr closed 7 years ago

kmmbvnr commented 7 years ago

If the table header contains an element with id attribute, the FixedHeader would duplicate it in the table header clone. This breaks other js code relying on that id's.

I have this issue with a checkbox in a table header.


- itemDom.placeholder = itemElement.clone( false );
+ var clonedElement = itemElement.clone( false )
+ clonedElement.find("*[id]").attr('id',function(i,id){ return id+"_cloned"; });
+ clonedElement.find("*[for]").attr('for',function(i,id){ return id+"_cloned"; });
+ itemDom.placeholder  = clonedElement;
``
DataTables commented 7 years ago

Thanks for this! Rather than modifying the id, I've just removed it as I'm not sure anyone would find the cloned id easily. I've also not removed the for attribute - as far as I am aware they don't need to be unique so I don't think they would cause any issues (I could be wrong!).