diff options
| author | Mark Otto <[email protected]> | 2016-11-26 17:02:40 -0800 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2016-11-26 17:02:40 -0800 |
| commit | 87a0749f891e64a38b4be1806e59cffb250501ce (patch) | |
| tree | 0c698d3725c4dfaf91a82ad5376b84f8de92d12e | |
| parent | 181e124bc1fed117a562698cafcc3be6b107eb65 (diff) | |
| parent | 0ded703f6bb7b0c60b1ec8e90592c845ca07d46e (diff) | |
| download | bootstrap-87a0749f891e64a38b4be1806e59cffb250501ce.tar.xz bootstrap-87a0749f891e64a38b4be1806e59cffb250501ce.zip | |
Merge branch 'container-tooltip-option' into v4-dev
| -rw-r--r-- | docs/components/tooltips.md | 2 | ||||
| -rw-r--r-- | js/src/tooltip.js | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/docs/components/tooltips.md b/docs/components/tooltips.md index b6dc451ec..31fb2c1c7 100644 --- a/docs/components/tooltips.md +++ b/docs/components/tooltips.md @@ -165,7 +165,7 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap </tr> <tr> <td>container</td> - <td>string | false</td> + <td>string | element | false</td> <td>false</td> <td> <p>Appends the tooltip to a specific element. Example: <code>container: 'body'</code>. This option is particularly useful in that it allows you to position the tooltip in the flow of the document near the triggering element - which will prevent the tooltip from floating away from the triggering element during a window resize.</p> diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 822ae3652..94f77a2a4 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -46,7 +46,8 @@ const Tooltip = (($) => { selector : false, placement : 'top', offset : '0 0', - constraints : [] + constraints : [], + container : false } const DefaultType = { @@ -59,7 +60,8 @@ const Tooltip = (($) => { selector : '(string|boolean)', placement : '(string|function)', offset : 'string', - constraints : 'array' + constraints : 'array', + container : '(string|element|boolean)' } const AttachmentMap = { @@ -274,9 +276,11 @@ const Tooltip = (($) => { const attachment = this._getAttachment(placement) + const container = this.config.container === false ? document.body : $(this.config.container) + $(tip) .data(this.constructor.DATA_KEY, this) - .appendTo(document.body) + .appendTo(container) $(this.element).trigger(this.constructor.Event.INSERTED) |
