Several directives in Angular UI Bootstrap have an append-to-body
option. When would I need to use this and what are the advantages and disadvantages to it?
That's a very useful option.
That option changes parent of any tooltips etc. elements that as usual dynamicly added into your HTML. To prevent some edges collisions or mixing CSS rules.
You will need to use that option when for example your tooltips are cut by parent edges (parent has overflow:hidden). When using that append-to-body option tooltip will be appended to body instead of that overflow:hidden parent and will not be cut.
Quick solution for such often happening issue.
I have found such options useful because otherwise the markup would be inserted as a sibling or child of the triggering element, which may not be ideal.
Possible reasons why:
- They would inherit styles that shouldn't apply to them
- The markup that would be inserted would be invalid if inserted there (e.g. a
<div>
as a child of a<tr>
). - They need to be absolutely positioned, and by making them a child of body, this enables them to be positioned on the page correctly, but still scroll with the page (as opposed to
position: fixed
, which does not scroll with the page).
There are probably other reasons, but I suspect that the last one is the most common.
© 2022 - 2024 — McMap. All rights reserved.