diff --git a/docs/components/dropdowns.md b/docs/components/dropdowns.md index 938447f3d6..7aa91773cf 100644 --- a/docs/components/dropdowns.md +++ b/docs/components/dropdowns.md @@ -568,6 +568,7 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap | Method | Description | | --- | --- | | `$().dropdown('toggle')` | Toggles the dropdown menu of a given navbar or tabbed navigation. | +| `$().dropdown('update')` | Updates the position of an element's dropdown. | ### Events diff --git a/docs/components/popovers.md b/docs/components/popovers.md index 9366ac1a1d..714bb0abcf 100644 --- a/docs/components/popovers.md +++ b/docs/components/popovers.md @@ -322,6 +322,12 @@ Toggles the ability for an element's popover to be shown or hidden. {% highlight js %}$('#element').popover('toggleEnabled'){% endhighlight %} +#### `.popover('update')` + +Updates the position of an element's popover. + +{% highlight js %}$('#element').popover('update'){% endhighlight %} + ### Events diff --git a/docs/components/tooltips.md b/docs/components/tooltips.md index 54f3c448f5..6d6d2a26a0 100644 --- a/docs/components/tooltips.md +++ b/docs/components/tooltips.md @@ -298,6 +298,12 @@ Toggles the ability for an element's tooltip to be shown or hidden. {% highlight js %}$('#element').tooltip('toggleEnabled'){% endhighlight %} +#### `.tooltip('update')` + +Updates the position of an element's tooltip. + +{% highlight js %}$('#element').tooltip('update'){% endhighlight %} + ### Events
diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 613a238128..0c082edd60 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -185,8 +185,14 @@ const Dropdown = (($) => { if (this._popper !== null) { this._popper.destroy() } + this._popper = null } + update() { + if (this._popper !== null) { + this._popper.scheduleUpdate() + } + } // private diff --git a/js/src/tooltip.js b/js/src/tooltip.js index a8c0ab6f1d..d50ddbb3e8 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -227,6 +227,9 @@ const Tooltip = (($) => { this._timeout = null this._hoverState = null this._activeTrigger = null + if (this._popper !== null) { + this._popper.destroy() + } this._popper = null this.element = null @@ -385,6 +388,11 @@ const Tooltip = (($) => { } + update() { + if (this._popper !== null) { + this._popper.scheduleUpdate() + } + } // protected @@ -646,8 +654,8 @@ const Tooltip = (($) => { } _handlePopperPlacementChange(data) { - this._cleanTipClass() - this.addAttachmentClass(this._getAttachment(data.placement)) + this._cleanTipClass() + this.addAttachmentClass(this._getAttachment(data.placement)) } // static