Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #39684
| Subject | Re: Using HTML5 templates |
|---|---|
| Newsgroups | comp.lang.javascript |
| References | <HISdnR0V-cLSFcz9nZ2dnUU7-bfNnZ2d@westnet.com.au> <978657c1-32a8-414c-892a-1bbd6d988e62n@googlegroups.com> |
| From | Andrew Poulos <ap_prog@hotmail.com> |
| Date | 2021-03-18 07:47 +1100 |
| Message-ID | <69SdnePHA55U98_9nZ2dnUU7-eGdnZ2d@westnet.com.au> (permalink) |
On 18/03/2021 12:08 am, Michael Haufe (TNO) wrote: > On Tuesday, March 16, 2021 at 11:40:58 PM UTC-5, Andrew Poulos wrote: >> If I have a simple template that looks like this >> >> <template id="my-paragraph"> >> <p id="foo">My paragraph</p> >> </template> >> >> When I clone the template multiple times I have multiple elements with >> the id of "foo". >> >> So if the template I've be given to use is fairly large (with many >> elements with IDs) how would I use it? I suspect that before the clone >> is appended to the DOM I'll need to loop through all the elements and >> edit the IDs so that they are unique - which complicates referencing them. >> >> Is this correct or am I misunderstanding how a is to be used template? > > Correct, you'll want to remove the id's. > > Can you avoid having the id's in the template in the first place? Can you not use 'class' instead? > Thanks. Yes I could but it means tracking down any getElementById and replacing it with querySelector. Andrew Poulos
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Using HTML5 templates Andrew Poulos <ap_prog@hotmail.com> - 2021-03-17 15:40 +1100
Re: Using HTML5 templates "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-03-17 06:08 -0700
Re: Using HTML5 templates Andrew Poulos <ap_prog@hotmail.com> - 2021-03-18 07:47 +1100
csiph-web