Nnwinnade Ho Afotu
Nwoma ne nhwɛsoɔ a wɔde bɛka Bootstrap adwinnadeɛ a wɔahyɛ da ayɛ ho a CSS ne JavaScript de CSS3 di dwuma ma animations ne data-bs-attributes ma local title storage.
Nsɛm a Wɔaka abom
Nneɛma a ɛsɛ sɛ wuhu bere a wode tooltip plugin no redi dwuma no:
- Nnwinnade ho nsɛm de ne ho to nhomakorabea a ɛto so abiɛsa Popper so ma gyinabea. Ɛsɛ sɛ wode popper.min.js ka ho ansa na
bootstrap.js
, anaasɛ wode biakobootstrap.bundle.min.js
a Popper wom di dwuma. - Tooltips yɛ opt-in esiane adwumayɛ nti, enti ɛsɛ sɛ w’ankasa wufi ase .
- Nnwinnade ho nsɛm a ɛwɔ asɛmti a ne tenten yɛ zero no nkyerɛ da.
- Kyerɛkyerɛ
container: 'body'
sɛnea wobɛkwati nkyerɛase ho haw ahorow wɔ afã horow a ɛyɛ den kɛse mu (te sɛ yɛn nsɛm a wɔde hyɛ mu akuw, bɔtn akuw, ne nea ɛkeka ho). - Nnwinnade ho nsɛm a wobɛkanyan wɔ nneɛma a ahintaw so no rennyɛ adwuma.
- Ɛsɛ sɛ wɔde adwinnade afotu ma
.disabled
anaadisabled
element ahorow no fi ase wɔ wrapper element bi so. - Sɛ wofi ase fi hyperlink ahorow a ɛtrɛw nkyerɛwde ahorow pii mu a, adwinnade ho nsɛm bɛkɔ mfinimfini. Fa di dwuma
white-space: nowrap;
wɔ wo<a>
s so na woakwati saa suban yi. - Ɛsɛ sɛ wɔde nnwinnadeɛ ho nsɛm sie ansa na wɔayi wɔn nneɛma a ɛne no hyia no afiri DOM no mu.
- Tooltips betumi ayɛ triggered aseda element bi a ɛwɔ sunsuma DOM mu.
Woanya saa nneɛma no nyinaa? Ɔkɛseɛ, ma yɛnhwɛ sɛdeɛ wɔde nhwɛsoɔ bi yɛ adwuma.
prefers-reduced-motion
media asɛmmisa no so. Hwɛ
yɛn akwan a wɔfa so nya nneɛma ho nkrataa no fã a wɔatew so no .
Nhwɛso ahorow
Ma nnwinnade ho nyansahyɛ ahorow nyɛ adwuma
Sɛnea yɛaka wɔ atifi hɔ no, ɛsɛ sɛ wohyɛ adwinnade ho nsɛm ase ansa na woatumi de adi dwuma. Ɔkwan baako a wobɛfa so ahyɛ adwinnadeɛ a ɛwɔ kratafa bi so nyinaa ase ne sɛ wobɛpaw wɔn denam wɔn data-bs-toggle
su so, te sɛ saa:
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
Nnwinnade ho afotu a ɛwɔ link ahorow so
Fa wo nsa hyɛ link ahorow a ɛwɔ ase ha no so na wubehu nnwinnade ho nyansahyɛ ahorow:
Beaeɛ nsɛm a wɔde bɛkyerɛ inline links bi a ɛwɔ adwinnadeɛ ho nkyerɛkyerɛmu. Mprempren eyi yɛ filler ara kwa, owudifo biara nni hɔ. Nsɛm a wɔde ahyɛ ha sɛnea ɛbɛyɛ a wobesuasua nkyerɛwee ankasa a ɛwɔ hɔ no ara kwa . Na ne nyinaa sɛnea ɛbɛyɛ a wubenya adwene wɔ sɛnea nnwinnade ho nyansahyɛ ahorow bɛyɛ bere a wɔde di dwuma wɔ wiase tebea horow ankasa mu no ho ara kwa. Enti anidasoɔ wɔ mu sɛ seesei woahunu sɛdeɛ saa nnwinnadeɛ a ɛwɔ links so yi bɛtumi ayɛ adwuma wɔ nneyɛeɛ mu, berɛ a wode adi dwuma wɔ w’ankasa wo site anaa project so no.
<p class="muted">Placeholder text to demonstrate some <a href="#" data-bs-toggle="tooltip" data-bs-title="Default tooltip">inline links</a> with tooltips. This is now just filler, no killer. Content placed here just to mimic the presence of <a href="#" data-bs-toggle="tooltip" data-bs-title="Another tooltip">real text</a>. And all that just to give you an idea of how tooltips would look when used in real-world situations. So hopefully you've now seen how <a href="#" data-bs-toggle="tooltip" data-bs-title="Another one here too">these tooltips on links</a> can work in practice, once you use them on <a href="#" data-bs-toggle="tooltip" data-bs-title="The last tip!">your own</a> site or project.
</p>
title
anaa
data-bs-title
wo HTML mu bedi dwuma. Sɛ
title
wɔde di dwuma a, Popper bɛsesa no ankasa de
data-bs-title
bere a wɔakyerɛ element no ase.
Nnwinnade ho nyansahyɛ ahorow a wɔahyɛ da ayɛ
Wɔde aka ho wɔ v5.2.0 muWubetumi de CSS variables ayɛ adwinnade ho nsɛm a ɛbɛda adi no ho nhyehyɛe . Yɛde custom class bi si hɔ de data-bs-custom-class="custom-tooltip"
to scope yɛn custom appearance na yɛde di dwuma de override local CSS variable bi so.
.custom-tooltip {
--bs-tooltip-bg: var(--bs-primary);
}
<button type="button" class="btn btn-secondary"
data-bs-toggle="tooltip" data-bs-placement="top"
data-bs-custom-class="custom-tooltip"
data-bs-title="This top tooltip is themed via CSS variables.">
Custom tooltip
</button>
Akwankyerɛ ahorow
Fa wo nsa hyɛ bɔtn a ɛwɔ ase hɔ no so na wubehu adwinnade ho akwankyerɛ anan no: soro, nifa, ase, ne benkum. Akwankyerɛ ahorow no yɛ ahwehwɛ bere a wode Bootstrap redi dwuma wɔ RTL mu no.
<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="Tooltip on top">
Tooltip on top
</button>
<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="right" data-bs-title="Tooltip on right">
Tooltip on right
</button>
<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-title="Tooltip on bottom">
Tooltip on bottom
</button>
<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="left" data-bs-title="Tooltip on left">
Tooltip on left
</button>
Na ɛne HTML a wɔahyɛ da ayɛ a wɔde aka ho no:
<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-html="true" data-bs-title="<em>Tooltip</em> <u>with</u> <b>HTML</b>">
Tooltip with HTML
</button>
Sɛ wode SVG di dwuma a:
CSS a ɛwɔ hɔ no
Nneɛma a Ɛsakra
Wɔde aka ho wɔ v5.2.0 muSɛ́ Bootstrap CSS nsakrae kwan a ɛrekɔ so no fã no, mprempren nnwinnade ho nkyerɛkyerɛmu de mpɔtam hɔ CSS nsakrae ahorow di dwuma wɔ so .tooltip
ma bere ankasa mu nsakrae a ɛkɔ anim. Wɔde Sass so ahyɛ CSS nsakraeɛ no botaeɛ, enti Sass nhyehyɛɛ no da so ara boa, nso.
--#{$prefix}tooltip-zindex: #{$zindex-tooltip};
--#{$prefix}tooltip-max-width: #{$tooltip-max-width};
--#{$prefix}tooltip-padding-x: #{$tooltip-padding-x};
--#{$prefix}tooltip-padding-y: #{$tooltip-padding-y};
--#{$prefix}tooltip-margin: #{$tooltip-margin};
@include rfs($tooltip-font-size, --#{$prefix}tooltip-font-size);
--#{$prefix}tooltip-color: #{$tooltip-color};
--#{$prefix}tooltip-bg: #{$tooltip-bg};
--#{$prefix}tooltip-border-radius: #{$tooltip-border-radius};
--#{$prefix}tooltip-opacity: #{$tooltip-opacity};
--#{$prefix}tooltip-arrow-width: #{$tooltip-arrow-width};
--#{$prefix}tooltip-arrow-height: #{$tooltip-arrow-height};
Sass nsakrae ahorow
$tooltip-font-size: $font-size-sm;
$tooltip-max-width: 200px;
$tooltip-color: $white;
$tooltip-bg: $black;
$tooltip-border-radius: $border-radius;
$tooltip-opacity: .9;
$tooltip-padding-y: $spacer * .25;
$tooltip-padding-x: $spacer * .5;
$tooltip-margin: null; // TODO: remove this in v6
$tooltip-arrow-width: .8rem;
$tooltip-arrow-height: .4rem;
// fusv-disable
$tooltip-arrow-color: null; // Deprecated in Bootstrap 5.2.0 for CSS variables
// fusv-enable
Sɛnea wɔde di dwuma
Adwinnade ho nkyerɛkyerɛmu plugin no yɛ nsɛm ne agyiraehyɛde wɔ ahwehwɛde so, na sɛnea ɛte no, ɛde adwinnade ho nsɛm si wɔn trigger element no akyi.
Fa JavaScript so na ɛkanyan adwinnade no:
const exampleEl = document.getElementById('example')
const tooltip = new bootstrap.Tooltip(exampleEl, options)
Overflow auto
nescroll
Tooltip gyinabea bɔ mmɔden sɛ ɛbɛsakra ne ho bere a ɔwofo container wɔ overflow: auto
anaa overflow: scroll
ɛte yɛn .table-responsive
, nanso ɛda so ara kura mfitiase beae no gyinabea. Sɛ wopɛ sɛ wosiesie eyi a, hyehyɛ boundary
nhyehyɛe no (ma flip modifier a ɔde popperConfig
option no bedi dwuma) wɔ HTMLElement biara so de abɔ default value no so, 'clippingParents'
, te sɛ document.body
:
const tooltip = new bootstrap.Tooltip('#example', {
boundary: document.body // or document.querySelector('#boundary')
})
Markup a wɔde hyɛ agyirae
Agyiraehyɛde a wɔhwehwɛ ma adwinnade ho nkyerɛkyerɛmu no yɛ data
su bi nkutoo na title
wɔ HTML element no so no wopɛ sɛ wunya adwinnade ho nsɛm. Nnwinnade bi agyiraehyɛde a wɔayɛ no yɛ mmerɛw mmom, ɛwom sɛ ɛhwehwɛ gyinabea (default no, wɔde ahyɛ mu top
denam plugin no so).
Nnwinnade ho nkyerɛkyerɛmu a wɔbɛma ayɛ adwuma ama keyboard ne mfiridwuma a ɛboa wɔn a wɔde di dwuma no
Ɛsɛ sɛ wode nnwinnadeɛ ho nkyerɛkyerɛmu ka HTML nneɛma a ɛyɛ atetesɛm no keyboard-focusable ne nkitahodiɛ (te sɛ links anaa form controls) nko ara ho. Ɛwom sɛ wobetumi ama HTML nneɛma a wɔpɛ (te sɛ <span>
s) ayɛ nea wɔde wɔn adwene si so denam tabindex="0"
su no a wɔde bɛka ho so de, nanso eyi bɛma tab gyinabea ahorow a ebetumi ayɛ abufuw na ɛyɛ basaa bɛka nneɛma a ɛnyɛ nkitahodi ho ama keyboard dwumadiefoɔ, na mprempren mmoa mfiridwuma dodow no ara mfa adwinnade no ho asɛm mma wɔ tebea yi mu. Bio nso, mfa wo ho nto so hover
sɛ ɛno nkutoo na ɛbɛkanyan wo adwinnade ho nyansahyɛ no, efisɛ eyi bɛma wo adwinnade ho nsɛm no anyɛ yiye sɛ ɛbɛkanyan wɔn a wɔde keyboard di dwuma no.
<!-- HTML to write -->
<a href="#" data-bs-toggle="tooltip" data-bs-title="Some tooltip text!">Hover over me</a>
<!-- Generated markup by the plugin -->
<div class="tooltip bs-tooltip-top" role="tooltip">
<div class="tooltip-arrow"></div>
<div class="tooltip-inner">
Some tooltip text!
</div>
</div>
Nneɛma a wɔadi dɛm
Elements a ɛwɔ disabled
attribute no nyɛ nkitahodi, a ɛkyerɛ sɛ wɔn a wɔde di dwuma no ntumi mfa wɔn adwene nsi wɔn so, wɔmfa wɔn ho nhyɛ mu, anaasɛ wɔmfa wɔn nsa nka wɔn mfa nhyɛ adwinnade ho nsɛm (anaasɛ popover) ase. Sɛ́ ɔkwan a wobɛfa so ayɛ adwuma no, wobɛpɛ sɛ wokanyan adwinnade no asɛm no fi wrapper <div>
anaa <span>
, a eye sen biara a wɔayɛ no keyboard-focusable denam tabindex="0"
.
<span class="d-inline-block" tabindex="0" data-bs-toggle="tooltip" data-bs-title="Disabled tooltip">
<button class="btn btn-primary" type="button" disabled>Disabled button</button>
</span>
Nneɛma a wubetumi apaw
Sɛnea wobetumi afa data attributes anaa JavaScript so de options no atwam no, wubetumi de option din ahyɛ data-bs-
, sɛnea ɛwɔ data-bs-animation="{value}"
. Hwɛ hu sɛ wobɛsesa case type a ɛwɔ option din no mu afi “ camelCase ” akɔ “ kebab-case ” bere a wode options no nam data attributes so retwam no. Sɛ nhwɛso no, fa di dwuma data-bs-custom-class="beautifier"
mmom sen sɛ wode data-bs-customClass="beautifier"
.
Ɛde besi Bootstrap 5.2.0 no, nneɛma no nyinaa boa nhwehwɛmu a wɔde asie data su data-bs-config
a ebetumi de afã nhyehyɛe a ɛnyɛ den ahyɛ mu sɛ JSON ahama. Sɛ element bi wɔ data-bs-config='{"delay":0, "title":123}'
ne data-bs-title="456"
su ahorow a, botae a etwa to title
no bɛyɛ 456
na data su ahorow a ɛtetew mu no bɛbɔ botae ahorow a wɔde ama wɔ data-bs-config
. Bio nso, data su ahorow a ɛwɔ hɔ dedaw no tumi de JSON botae ahorow te sɛ data-bs-delay='{"show":0,"hide":150}'
.
sanitize
,
sanitizeFn
, ne
options no mma.allowList
Din | Korɔ | Mfiaseɛ | Nkyerɛmu |
---|---|---|---|
allowList |
adeɛ | Default bo a ɛsom | Adeɛ a ɛwɔ su ne tags a wɔama ho kwan. |
animation |
boolean ho asɛm | true |
Fa CSS fade nsakrae bi di dwuma wɔ adwinnade no ho. |
boundary |
ahama, element | 'clippingParents' |
Overflow anohyeto hye a ɛwɔ adwinnade no ano (ɛfa Popper preventOverflow modifier nkutoo ho). Sɛnea wɔahyɛ no, ɛyɛ 'clippingParents' na ebetumi agye HTMLElement nkyerɛkyerɛmu (ɛnam JavaScript nkutoo so). Sɛ wopɛ nsɛm pii a hwɛ Popper detectOverflow docs . |
container |
ahama, element, atoro | false |
Fa adwinnade no ho nkyerɛkyerɛmu no ka element pɔtee bi ho. Nhwɛso: container: 'body' . Saa nhyehyeɛ yi ho wɔ mfasoɔ titire wɔ sɛdeɛ ɛma wo kwan ma wode adwinnadeɛ no si krataa no nsuo mu wɔ baabi a ɛbɛn triggering element no - a ɛbɛsi adwinnadeɛ no kwan sɛ ɛbɛsen afiri adeɛ a ɛkanyan no mu wɔ mfɛnsere kɛseɛ a wɔresakra no mu. |
customClass |
ahama, dwumadie | '' |
Fa adesua ahorow ka adwinnade no ho bere a wɔakyerɛ no. Hyɛ no nsow sɛ wɔde saa adesua ahorow yi bɛka adesua ahorow biara a wɔakyerɛ wɔ nsusuwso no mu no ho. Sɛ wode adesua ahorow pii bɛka ho a, fa ahunmu tetew mu: 'class-1 class-2' . Wubetumi nso de dwumadie bi a ɛsɛ sɛ ɛsan de ahama baako a adesua din foforɔ wom ba no atwam. |
delay |
nɔma, ade | 0 |
Delay showing and hide tooltip (ms)—ɛnfa manual trigger type ho. Sɛ wɔde nɔma bi ma a, wɔde delay di dwuma wɔ hide/show abien no nyinaa mu. Nneɛma nhyehyɛe ne: delay: { "show": 500, "hide": 100 } . |
fallbackPlacements |
array a ɛwɔ hɔ | ['top', 'right', 'bottom', 'left'] |
Kyerɛkyerɛ fallback placements mu denam placements list a wode bɛma wɔ array mu (sɛnea wopɛ nnidiso nnidiso). Sɛ wopɛ nsɛm pii a hwɛ Popper's behavior docs . |
html |
boolean ho asɛm | false |
Ma HTML kwan wɔ adwinnade no mu. Sɛ ɛyɛ nokware a, HTML tags a ɛwɔ adwinnade no mu no title bɛkyerɛ ase wɔ adwinnade no mu. Sɛ ɛyɛ atoro a, innerText wɔde agyapadeɛ bedi dwuma de ahyɛ nsɛm a ɛwɔ DOM no mu. Fa text di dwuma sɛ XSS ntua ho asɛm haw wo a. |
offset |
array, ahama, dwumadie | [0, 0] |
Offset a ɛwɔ adwinnade no a wɔde toto ne botae no ho. Wubetumi de ahama bi akɔ data su ahorow mu a ɛwɔ botae ahorow a wɔatew mu wɔ koma mu te sɛ: data-bs-offset="10,20" . Sɛ wɔde dwumadie bi di dwuma de kyerɛ offset no a, wɔde adeɛ bi a ɛwɔ popper placement, reference, ne popper rects sɛ ne argument a ɛdi kan no frɛ no. Wɔde triggering element DOM node no twam sɛ akyinnyegye a ɛto so abien. Ɛsɛ sɛ dwumadie no san de array a ɛwɔ nɔma mmienu ba: skidding , distance . Sɛ wopɛ nsɛm pii a hwɛ Popper's offset docs . |
placement |
ahama, dwumadie | 'top' |
Sɛnea wode adwinnade no si hɔ: auto, soro, ase, benkum, nifa. Sɛ auto wɔkyerɛ a, ɛbɛsan akyerɛ adwinnade no kwan wɔ ɔkwan a ɛyɛ nnam so. Sɛ wɔde dwumadie bi di dwuma de kyerɛ beaeɛ a wɔde bɛto a, wɔfrɛ no a adwinnadeɛ tip DOM node yɛ ne asɛm a ɛdi kan na triggering element DOM node yɛ nea ɛtɔ so mmienu. Wɔde this nsɛm a ɛfa ho no asi adwinnade ho nhwɛso no so. |
popperConfig |
null, ade, dwumadie | null |
Sɛ wopɛ sɛ wosakra Bootstrap no Popper nhyehyɛe a ɛwɔ hɔ dedaw no a, hwɛ Popper nhyehyɛe . Sɛ wɔde dwumadie bi di dwuma de yɛ Popper nhyehyeɛ no a, wɔde adeɛ bi a ɛwɔ Bootstrap no Popper nhyehyeɛ a ɛwɔ hɔ dedaw no frɛ no. Ɛboa wo ma wode default no di dwuma na wode bom ne w’ankasa nhyehyɛe. Ɛsɛ sɛ dwumadie no san de nhyehyɛɛ adeɛ bi ba ma Popper. |
sanitize |
boolean ho asɛm | true |
Ma sanitization no nyɛ adwuma anaasɛ ɛnnyɛ adwuma. If activated 'template' , 'content' na 'title' options no bɛyɛ sanitized. |
sanitizeFn |
null, dwumadie | null |
Ɛha na wubetumi de w’ankasa sanitize adwuma ama. Eyi betumi ayɛ nea mfaso wɔ so sɛ wopɛ sɛ wode nhomakorabea a wɔatu ho ama di dwuma de yɛ ahotew a. |
selector |
ahama, atoro | false |
Sɛ wɔde selector bi ma a, wɔde tooltip nneɛma bɛhyɛ botae ahorow a wɔakyerɛ no nsa. Wɔ nneyɛe mu no, wɔde eyi nso di dwuma de nnwinnade ho nsɛm nso di dwuma wɔ DOM nneɛma a wɔde aka ho wɔ ɔkwan a ɛyɛ nnam so ( jQuery.on mmoa). Hwɛ saa nsɛmma nhoma yi ne nhwɛso a ɛma nsɛm pii . |
template |
ahoma | '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' |
Base HTML a wode bedi dwuma bere a woreyɛ adwinnade no ho nsɛm. Wɔde adwinnade no title ano aduru no bɛhyɛ .tooltip-inner . .tooltip-arrow bɛyɛ adwinnade no agyan. Ɛsɛ sɛ wrapper element a ɛwɔ akyi paa no nya .tooltip class ne role="tooltip" . |
title |
ahama, element, dwumadie | '' |
Default title value sɛ title attribute no nni hɔ a. Sɛ wɔde dwumadie bi ma a, wɔbɛfrɛ no a ne this nkyerɛkyerɛmu no ahyɛ element a popover no abata ho no ho. |
trigger |
ahoma | 'hover focus' |
Sɛnea wɔhyɛ adwinnade ho asɛm no ase: klik, hover, focus, manual. Wubetumi atwam wɔ nneɛma pii a ɛkanyan adwene mu; fa ahunmu tetew wɔn mu. 'manual' kyerɛ sɛ wɔbɛkanyan adwinnade no wɔ nhyehyɛe kwan so denam .tooltip('show') , .tooltip('hide') ne .tooltip('toggle') akwan horow so; saa botae yi ntumi nka ho ne trigger foforo biara. 'hover' n’ankasa bɛma adwinnade ho nsɛm a wontumi mfa keyboard no so nhyɛ ase, na sɛ akwan foforo a wɔfa so de nsɛm koro no ara ma wɔn a wɔde keyboard di dwuma no wɔ hɔ nkutoo a, ɛsɛ sɛ wɔde di dwuma. |
Data su ahorow ma ankorankoro nnwinnade ho nkyerɛkyerɛmu
Wobetumi akyerɛ akwan foforo a wɔbɛfa so akyerɛ ankorankoro adwinnade ho nkyerɛkyerɛmu denam data su ahorow a wɔde bedi dwuma so, sɛnea wɔakyerɛkyerɛ mu wɔ atifi hɔ no.
Dwumadi a wɔde di dwuma nepopperConfig
const tooltip = new bootstrap.Tooltip(element, {
popperConfig(defaultBsPopperConfig) {
// const newPopperConfig = {...}
// use defaultBsPopperConfig if needed...
// return newPopperConfig
}
})
Akwan a wɔfa so yɛ
Asynchronous akwan ne nsakrae ahorow
API akwan nyinaa yɛ asynchronous na ɛhyɛ nsakrae ase . Wɔsan kɔ nea ɔfrɛɛ no no nkyɛn bere a wɔafi nsakrae no ase ara pɛ nanso ansa na aba awiei . Bio nso, wobebu ani agu ɔkwan a wɔfa so frɛ ade bi a ɛresakra so no so .
Ɔkwan | Nkyerɛmu |
---|---|
disable |
Yi tumi a ɛwɔ element bi adwinnade a wɔde bɛkyerɛ no fi hɔ. Sɛ wɔsan yɛ adwuma nkutoo a, wobetumi akyerɛ adwinnade no. |
dispose |
Hide na ɛsɛe element bi adwinnade tip (Eyi data a wɔde asie wɔ DOM element no so). Nnwinnade a wɔde delegation di dwuma (a wɔde option ) na ɛyɛe noselector ntumi nsɛe no ankorankoro wɔ descendant trigger elements so. |
enable |
Ɛma element bi tooltip tumi a wɔde bɛkyerɛ. Nnwinnade ho nsɛm no yɛ nea wɔahyɛ da ayɛ. |
getInstance |
Static kwan a ɛma wo kwan ma wo nya tooltip instance a ɛbata DOM element bi ho, anaasɛ wobɔ foforo sɛ ɛba sɛ wɔanhyɛ aseɛ a. |
getOrCreateInstance |
Static kwan a ɛma wo kwan ma wo nya tooltip instance a ɛbata DOM element bi ho, anaasɛ wobɔ foforo sɛ ɛba sɛ wɔanhyɛ aseɛ a. |
hide |
Fa element bi adwinnade ho nsɛm sie. San kɔ nea ɔfrɛ no no nkyɛn ansa na wɔde adwinnade no asie ankasa (kyerɛ sɛ ansa na hidden.bs.tooltip asɛm no asi). Wobu eyi sɛ “nsaano” a wɔde kanyan adwinnade no ho asɛm. |
setContent |
Ɛma ɔkwan a wobɛfa so asesa adwinnade no mu nsɛm wɔ ne mfiase akyi. |
show |
Ɛda element bi adwinnade ho nsɛm adi. San kɔ nea ɔfrɛ no no nkyɛn ansa na wɔada adwinnade no adi ankasa (kyerɛ sɛ ansa na shown.bs.tooltip asɛm no asi). Wobu eyi sɛ “nsaano” a wɔde kanyan adwinnade no ho asɛm. Nnwinnade ho nsɛm a ɛwɔ asɛmti a ne tenten yɛ zero no nkyerɛ da. |
toggle |
Toggles element bi adwinnade ho nsɛm. San kɔ nea ɔfrɛ no no nkyɛn ansa na wɔakyerɛ adwinnade no asɛm no ankasa anaa wɔde asie (kyerɛ sɛ ansa na shown.bs.tooltip anaa hidden.bs.tooltip adeyɛ no aba). Wobu eyi sɛ “nsaano” a wɔde kanyan adwinnade no ho asɛm. |
toggleEnabled |
Toggles tumi a element bi adwinnade tip bɛkyerɛ anaa wɔde asie. |
update |
Ɔyɛ element bi adwinnade tip no gyinabea foforo. |
const tooltip = bootstrap.Tooltip.getInstance('#example') // Returns a Bootstrap tooltip instance
// setContent example
tooltip.setContent({ '.tooltip-inner': 'another title' })
setContent
no gye
object
akyinnyegye bi tom, baabi a agyapade-safoa biara yɛ
string
pawfo a ɛfata wɔ popover nsusuwso no mu, na agyapade-botae biara a ɛfa ho no betumi ayɛ
string
|
element
|
function
|
null
Nsɛm a esisi
Dwumadie | Nkyerɛmu |
---|---|
hide.bs.tooltip |
Wɔtow saa adeyɛ yi ntɛm ara bere a hide wɔafrɛ instance kwan no. |
hidden.bs.tooltip |
Wɔtow saa adeyɛ yi bere a popover no awie a wɔde asie ama ɔdefo no (bɛtwɛn ma CSS nsakrae ahorow no awie). |
inserted.bs.tooltip |
Wɔtow saa adeyɛ yi wɔ adeyɛ no akyi show.bs.tooltip bere a wɔde adwinnade nkyerɛkyerɛmu nsusuwso no aka DOM no ho. |
show.bs.tooltip |
Saa adeyɛ yi tow ntɛm ara bere a show wɔfrɛ instance kwan no. |
shown.bs.tooltip |
Wɔtow saa adeyɛ yi bere a wɔayɛ popover no ahu nea ɔde di dwuma no (bɛtwɛn ma CSS nsakrae ahorow no awie). |
const myTooltipEl = document.getElementById('myTooltip')
const tooltip = bootstrap.Tooltip.getOrCreateInstance(myTooltipEl)
myTooltipEl.addEventListener('hidden.bs.tooltip', () => {
// do something...
})
tooltip.hide()