@@ -59,8 +59,8 @@ The content of a hover card can be defined in two ways:
5959
60601. Via a turbo frame that is fetched from a URL. This is the preferred way if you want to lazily load the contents
6161 of the hover card when needed.
62- 2. Via an existing DOM element that is present (but hidden) in the document on page load. This is useful when the
63- content is already present and no additional fetching is necessary.
62+ 2. Via an existing ` < template > ` element that is present (but hidden) in the document on page load. This is useful when the
63+ content is already there and no additional fetching of data is necessary.
6464
6565### Asynchronous hover cards via turbo frame
6666
@@ -130,31 +130,27 @@ trigger element.
130130 </ a >
131131 </ body >
132132```
133- The hover card content can be placed at a convenient place in the DOM. The following attributes must be set on the
134- element to ensure it will be displayed correctly:
133+ The hover card content can be placed at a convenient place in the DOM. It is recommended to use a
134+ [template element](https://www.w3schools.com/TagS/tag_template.asp) for that purpose. Whichever element you use: it is
135+ required to assign the ID that was inserted in the trigger's `data-hover-card-popover-id` attribute.
135136
136- 1. The ID that was inserted in the trigger's `data-hover-card-popover-id` attribute.
137- 2. The element from 1 should be placed into a container that is hidden. You *can* use the
138- class `op-hover-card--hidden-container` for that or define your own CSS to hide the container.
137+ When a template is used, the hover card will be hidden automatically. If another type of element is used, you are
138+ responsible for ensuring its invisibility on your own.
139139
140- On page load, the hover card will be hidden automatically. When hovering over the trigger, the hover card will be
141- shown next to it.
140+ When hovering over the trigger, the hover card will be rendered floating next to it.
142141
143- Please note that the hover card "blueprint" provided in the DOM will be cloned and moved into another location as part
144- of displaying the card. The cloned elements ID will be removed to avoid duplicate IDs in the DOM.
145-
146- This is to say: do not apply logic or styling that depends on the ID of the hover card element itself, as the ID
147- will remain with the hidden original element.
142+ Please note that technically, the contents of the template will be *copied* into a popover element that is then
143+ placed next to the trigger. To avoid ID clashes, do not use IDs in the contents of the hover card.
148144
149145**Card content**:
150146```html
151147 <!-- Somewhere else in the DOM... -->
152148
153- <!-- Hidden container , so that the popover is hidden on page load -->
154- < div class =" op- hover-card--hidden-container ">
155- <!-- Actual hover card contents that will be rendered in a popover. Note the ID : -->
156- < div id =" work-package-hover-card-14 " class ="your-styling-classes ">
149+ <!-- Template , so that the popover is hidden on page load. Note the ID: -->
150+ < template id =" work-package- hover-card-14 ">
151+ <!-- Actual hover card contents that will be rendered in a popover: -->
152+ < div class ="your-styling-classes ">
157153 < p > Hover card with description text of work package 14!</ p >
158154 </ div >
159- </ div >
155+ </ template >
160156```
0 commit comments