mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-17 09:52:29 +01:00
Implement container option for tooltips and popovers.
This commit is contained in:
parent
308bc77dbb
commit
0ded703f6b
@ -165,7 +165,7 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>container</td>
|
<td>container</td>
|
||||||
<td>string | false</td>
|
<td>string | element | false</td>
|
||||||
<td>false</td>
|
<td>false</td>
|
||||||
<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>
|
<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>
|
||||||
|
@ -46,7 +46,8 @@ const Tooltip = (($) => {
|
|||||||
selector : false,
|
selector : false,
|
||||||
placement : 'top',
|
placement : 'top',
|
||||||
offset : '0 0',
|
offset : '0 0',
|
||||||
constraints : []
|
constraints : [],
|
||||||
|
container : false
|
||||||
}
|
}
|
||||||
|
|
||||||
const DefaultType = {
|
const DefaultType = {
|
||||||
@ -59,7 +60,8 @@ const Tooltip = (($) => {
|
|||||||
selector : '(string|boolean)',
|
selector : '(string|boolean)',
|
||||||
placement : '(string|function)',
|
placement : '(string|function)',
|
||||||
offset : 'string',
|
offset : 'string',
|
||||||
constraints : 'array'
|
constraints : 'array',
|
||||||
|
container : '(string|element|boolean)'
|
||||||
}
|
}
|
||||||
|
|
||||||
const AttachmentMap = {
|
const AttachmentMap = {
|
||||||
@ -274,9 +276,11 @@ const Tooltip = (($) => {
|
|||||||
|
|
||||||
const attachment = this._getAttachment(placement)
|
const attachment = this._getAttachment(placement)
|
||||||
|
|
||||||
|
const container = this.config.container === false ? document.body : $(this.config.container)
|
||||||
|
|
||||||
$(tip)
|
$(tip)
|
||||||
.data(this.constructor.DATA_KEY, this)
|
.data(this.constructor.DATA_KEY, this)
|
||||||
.appendTo(document.body)
|
.appendTo(container)
|
||||||
|
|
||||||
$(this.element).trigger(this.constructor.Event.INSERTED)
|
$(this.element).trigger(this.constructor.Event.INSERTED)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user