Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the reasons for append-to-body in Angular Bootstrap?

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?

like image 910
David says Reinstate Monica Avatar asked Nov 18 '14 23:11

David says Reinstate Monica


Video Answer


2 Answers

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.

like image 116
Rantiev Avatar answered Oct 18 '22 22:10

Rantiev


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.

like image 28
GregL Avatar answered Oct 19 '22 00:10

GregL