Popovers a wɔde wɔn ho hyɛ mu
Nwoma ne nhwɛsoɔ a wode bɛka Bootstrap popovers, te sɛ deɛ wɔhunu wɔ iOS mu, wɔ element biara a ɛwɔ wo site no so.
Nsɛm a Wɔaka abom
Nneɛma a ɛsɛ sɛ wuhu bere a wode popover plugin no redi dwuma no:
- Popovers de wɔn 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. - Popovers hwehwɛ popover plugin no sɛ ade a ɛde ne ho to so.
- Popovers yɛ opt-in esiane adwumayɛ nti, enti ɛsɛ sɛ w’ankasa wufi ase .
- Zero-tenten
title
necontent
gyinapɛn ahorow renkyerɛ popover 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). - Popovers a wɔbɛkanyan wɔ nneɛma a ahintaw so no rennyɛ adwuma.
- Ɛsɛ sɛ wɔkanyan popovers ma
.disabled
anaadisabled
element ahorow wɔ wrapper element bi so. - Sɛ wɔkanyan no fi nhama a ɛkyekyere nsensanee pii so a, popovers no bɛkɔ mfinimfini wɔ ankora no nyinaa tɛtrɛtɛ ntam. Fa di dwuma
.text-nowrap
wɔ wo<a>
s so na woakwati saa suban yi. - Ɛsɛ sɛ wɔde popovers sie ansa na wɔayi wɔn nneɛma a ɛne no hyia no afi DOM no mu.
- Popovers betumi akanyan aseda element bi a ɛwɔ sunsuma DOM mu.
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 .
Kɔ so kenkan na hwɛ sɛnea popovers de nhwɛso ahorow bi yɛ adwuma.
Nhwɛso ahorow
Ma popovers nyɛ adwuma
Sɛnea yɛaka wɔ atifi hɔ no, ɛsɛ sɛ wohyɛ popovers ase ansa na wɔde adi dwuma. Ɔkwan baako a wobɛfa so ahyɛ popovers nyinaa ase wɔ krataafa bi so ne sɛ wobɛpaw wɔn denam wɔn data-bs-toggle
su so, te sɛ saa:
const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]')
const popoverList = [...popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl))
Live demo a ɛwɔ hɔ
Yɛde JavaScript a ɛte sɛ atifi hɔ snippet no di dwuma de kyerɛ live popover a edidi so yi ase. Wɔde asɛmti ahorow no si hɔ via data-bs-title
na wɔde nipadua mu nsɛm no si hɔ via data-bs-content
.
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.
<button type="button" class="btn btn-lg btn-danger" data-bs-toggle="popover" data-bs-title="Popover title" data-bs-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button>
Akwankyerɛ anan
Nneɛma anan na ɛwɔ hɔ: soro, nifa, ase, ne benkum. Akwankyerɛ ahorow no yɛ ahwehwɛ bere a wode Bootstrap redi dwuma wɔ RTL mu no. Fa si hɔ data-bs-placement
sɛ wobɛsesa akwankyerɛ no.
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="top" data-bs-content="Top popover">
Popover on top
</button>
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="right" data-bs-content="Right popover">
Popover on right
</button>
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="bottom" data-bs-content="Bottom popover">
Popover on bottom
</button>
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="left" data-bs-content="Left popover">
Popover on left
</button>
Amaneɛcontainer
Sɛ wowɔ style ahorow bi wɔ ɔwofo element bi so a ɛtwetwe popover bi a, wobɛpɛ sɛ wokyerɛ amanneɛbɔ bi sɛnea container
ɛbɛyɛ a popover no HTML bɛda adi wɔ saa element no mu mmom. Eyi abu so wɔ mmuae pon ahorow, nsɛm a wɔde hyɛ mu akuw, ne nea ɛtete saa mu.
const popover = new bootstrap.Popover('.example-popover', {
container: 'body'
})
Tebea foforo a wobɛpɛ sɛ wode amanne a ɛda adi pefee si hɔ container
ne popovers a ɛwɔ modal nkɔmmɔbɔ mu , de hwɛ hu sɛ wɔde popover no ankasa abata modal no ho. Eyi ho hia titiriw ma popovers a ɛwɔ nkitahodi nneɛma – modal nkɔmmɔbɔ bɛkyere adwene, enti gye sɛ popover no yɛ abofra ade wɔ modal no mu, wɔn a wɔde di dwuma no rentumi mfa wɔn adwene nsi so anaasɛ wɔmfa saa nkitahodi nneɛma yi nyɛ adwuma.
const popover = new bootstrap.Popover('.example-popover', {
container: '.modal-body'
})
Amanneɛ kwan so popovers
Wɔde aka ho wɔ v5.2.0 muWubetumi de CSS variables ayɛ sɛnea popovers no te no ho nhyehyɛe . Yɛde custom class bi si hɔ de data-bs-custom-class="custom-popover"
to scope yɛn custom appearance na yɛde di dwuma de bu local CSS variables no bi so.
.custom-popover {
--bs-popover-max-width: 200px;
--bs-popover-border-color: var(--bs-primary);
--bs-popover-header-bg: var(--bs-primary);
--bs-popover-header-color: var(--bs-white);
--bs-popover-body-padding-x: 1rem;
--bs-popover-body-padding-y: .5rem;
}
<button type="button" class="btn btn-secondary"
data-bs-toggle="popover" data-bs-placement="right"
data-bs-custom-class="custom-popover"
data-bs-title="Custom popover"
data-bs-content="This popover is themed via CSS variables.">
Custom popover
</button>
Dismiss wɔ klik a edi hɔ no so
Fa focus
trigger no yi popovers wɔ ɔdefo no klik a edi hɔ a ɛfa element soronko bi ho sen toggle element no so.
Markup pɔtee a ɛho hia ma dismiss-on-next-click
Sɛ wopɛ sɛ wobɔ cross-browser ne cross-platform suban yiye a, ɛsɛ sɛ wode <a>
tag no di dwuma, ɛnyɛ tag no <button>
, na ɛsɛ sɛ wode tabindex
attribute nso ka ho.
<a tabindex="0" class="btn btn-lg btn-danger" role="button" data-bs-toggle="popover" data-bs-trigger="focus" data-bs-title="Dismissible popover" data-bs-content="And here's some amazing content. It's very engaging. Right?">Dismissible popover</a>
const popover = new bootstrap.Popover('.popover-dismiss', {
trigger: 'focus'
})
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 nkɔ so anaasɛ wɔnkyere wɔn mfa nhyɛ popover (anaasɛ adwinnade ho nsɛm). Sɛ́ ano aduru no, wobɛpɛ sɛ wokanyan popover no fi wrapper <div>
anaa <span>
, a eye sen biara a wɔayɛ no keyboard-focusable denam tabindex="0"
.
Wɔ popover triggers a wɔadi dɛm ho no, ebia wobɛpɛ nso data-bs-trigger="hover focus"
sɛnea ɛbɛyɛ a popover no bɛda adi sɛ nsɛm a wɔde aniwa hu ntɛm ara ma wo dwumadiefoɔ no sɛdeɛ ebia wɔrenhwɛ kwan sɛ wɔbɛkliki element a wɔadi dɛm so.
<span class="d-inline-block" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-content="Disabled popover">
<button class="btn btn-primary" type="button" disabled>Disabled button</button>
</span>
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 popovers de mpɔtam hɔ CSS nsakrae ahorow di dwuma wɔ so .popover
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}popover-zindex: #{$zindex-popover};
--#{$prefix}popover-max-width: #{$popover-max-width};
@include rfs($popover-font-size, --#{$prefix}popover-font-size);
--#{$prefix}popover-bg: #{$popover-bg};
--#{$prefix}popover-border-width: #{$popover-border-width};
--#{$prefix}popover-border-color: #{$popover-border-color};
--#{$prefix}popover-border-radius: #{$popover-border-radius};
--#{$prefix}popover-inner-border-radius: #{$popover-inner-border-radius};
--#{$prefix}popover-box-shadow: #{$popover-box-shadow};
--#{$prefix}popover-header-padding-x: #{$popover-header-padding-x};
--#{$prefix}popover-header-padding-y: #{$popover-header-padding-y};
@include rfs($popover-header-font-size, --#{$prefix}popover-header-font-size);
--#{$prefix}popover-header-color: #{$popover-header-color};
--#{$prefix}popover-header-bg: #{$popover-header-bg};
--#{$prefix}popover-body-padding-x: #{$popover-body-padding-x};
--#{$prefix}popover-body-padding-y: #{$popover-body-padding-y};
--#{$prefix}popover-body-color: #{$popover-body-color};
--#{$prefix}popover-arrow-width: #{$popover-arrow-width};
--#{$prefix}popover-arrow-height: #{$popover-arrow-height};
--#{$prefix}popover-arrow-border: var(--#{$prefix}popover-border-color);
Sass nsakrae ahorow
$popover-font-size: $font-size-sm;
$popover-bg: $white;
$popover-max-width: 276px;
$popover-border-width: $border-width;
$popover-border-color: var(--#{$prefix}border-color-translucent);
$popover-border-radius: $border-radius-lg;
$popover-inner-border-radius: subtract($popover-border-radius, $popover-border-width);
$popover-box-shadow: $box-shadow;
$popover-header-font-size: $font-size-base;
$popover-header-bg: shade-color($popover-bg, 6%);
$popover-header-color: $headings-color;
$popover-header-padding-y: .5rem;
$popover-header-padding-x: $spacer;
$popover-body-color: $body-color;
$popover-body-padding-y: $spacer;
$popover-body-padding-x: $spacer;
$popover-arrow-width: 1rem;
$popover-arrow-height: .5rem;
Sɛnea wɔde di dwuma
Ma popovers nyɛ adwuma denam JavaScript so:
const exampleEl = document.getElementById('example')
const popover = new bootstrap.Popover(exampleEl, options)
Popovers a wɔbɛma ayɛ adwuma ama keyboard ne mfiridwuma a ɛboa wɔn a wɔde di dwuma no
Sɛ wobɛma keyboard dwumadiefoɔ atumi ayɛ wo popovers no adwuma a, ɛsɛ sɛ wode ka HTML elements a ɛyɛ atetesɛm no keyboard-focusable ne nkitahodiɛ (te sɛ links anaa form controls) nko ara. Ɛ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 mfiridwuma a ɛboa dodoɔ no ara mprempren mmɔ popover no mu nsɛm ho amanneɛ wɔ saa tebea yi mu . Bio nso, mfa wo ho nto so nkutoo hover
sɛ nea ɛkanyan wo popovers no, efisɛ eyi bɛma ayɛ den sɛ ɛbɛkanyan wɔn a wɔde keyboard di dwuma no.
Bere a wubetumi de HTML a ɛyɛ fɛ, a wɔahyehyɛ no ahyɛ popovers mu a html
wobɛpaw no, yɛhyɛ nyansa denneennen sɛ kwati sɛ wode nsɛm a ɛboro so bɛka ho. Ɔkwan a popovers fa so yɛ adwuma mprempren ne sɛ, sɛ wɔda no adi wie a, wɔde wɔn nsɛm no kyekyere trigger element a ɛwɔ aria-describedby
attribute no ho. Ne saa nti, wɔde popover no mu nsɛm nyinaa bɛto gua akyerɛ wɔn a wɔde mfiridwuma ho nimdeɛ a ɛboa di dwuma no sɛ nsu tenten biako a wontwa mu.
Bio nso, bere a ɛyɛ yiye sɛ wode nkitahodi controls (te sɛ form elements anaa links) nso bɛka wo popover no ho (denam saa elements yi a wode bɛka allowList
of allowed attributes and tags ho) no, hu sɛ mprempren popover no nhwɛ keyboard focus nhyehyɛe so. Sɛ keyboard dwumadie bi bue popover a, adwene kɔ so tra triggering element no so, na sɛdeɛ popover no taa nni trigger no akyi ntɛm ara wɔ document no nhyehyɛɛ mu no, biribiara nni hɔ a ɛkyerɛ sɛ wobɛkɔ anim/abɛmiaTABbɛma obi a ɔde keyboard di dwuma akɔ popover no ankasa mu. Ne tiawa mu no, sɛ wode nkitahodi nhyehyɛe ahorow bɛka popover ho kɛkɛ a, ɛda adi sɛ ɛbɛma saa nhyehyɛe ahorow yi ayɛ nea wontumi nkɔ/wɔrentumi mfa nni dwuma mma wɔn a wɔde keyboard di dwuma ne wɔn a wɔde mfiridwuma a ɛboa di dwuma, anaasɛ anyɛ yiye koraa no, ɛbɛma wɔanya nhyehyɛe a wɔde wɔn adwene si so nyinaa a ntease nnim. Wɔ saa nsɛm yi mu no, susuw ho sɛ wode modal nkɔmmɔbɔ bedi dwuma mmom.
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ɔ popover no so. |
boundary |
ahama, element | 'clippingParents' |
Overflow anohyeto hye a ɛwɔ popover no mu (ɛfa Popper preventOverflow modifier no 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 |
Ɛde popover 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 popover no si nwoma no nsuo mu wɔ baabi a ɛbɛn triggering element no - a ɛbɛsi popover no kwan sɛ ɛbɛsen akɔ akyirikyiri afiri triggering element no ho bere a woresakra mfɛnsere no kɛseɛ. |
content |
ahama, element, dwumadie | '' |
Default content value sɛ data-bs-content 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. |
customClass |
ahama, dwumadie | '' |
Fa adesua ahorow ka popover 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 hiding popover (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 |
ahama, nhyehyeɛ | ['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ɔ popover no mu. Sɛ ɛyɛ nokware a, HTML tags a ɛwɔ popover no mu no title bɛkyerɛ ase wɔ popover 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 |
nɔma, ahama, dwumadie | [0, 0] |
Offset of the popover sɛ wɔde toto ne botae ho a. 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 popover no besi hɔ: auto, soro, ase, benkum, nifa. Sɛ auto wɔkyerɛ a, ɛbɛsan akyerɛ popover 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 popover DOM node no yɛ ne akasakasa a ɛdi kan ne triggering element DOM node sɛ ne deɛ ɛtɔ so mmienu. Wɔde this nsɛm a ɛfa ho no asi popover 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 popover nneɛma bɛhyɛ botae ahorow a wɔakyerɛ no nsa. Wɔ nneyɛe mu no, wɔde eyi nso di dwuma de popovers di dwuma wɔ dynamically added DOM elements ( jQuery.on support). Hwɛ saa nsɛmma nhoma yi ne nhwɛso a ɛma nsɛm pii . |
template |
ahoma | '<div class="popover" role="popover"><div class="popover-arrow"></div><div class="popover-inner"></div></div>' |
Base HTML a wode bedi dwuma bere a woreyɛ popover no. Wɔde popover no title bɛhyɛ .popover-inner . .popover-arrow bɛyɛ popover no agyan. Ɛsɛ sɛ wrapper element a ɛwɔ akyi paa no nya .popover class ne role="popover" . |
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 popover fi 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 popover no wɔ nhyehyɛe kwan so denam .popover('show') , .popover('hide') ne .popover('toggle') akwan horow so; saa botae yi ntumi nka ho ne trigger foforo biara. 'hover' n’ankasa bɛma popovers a wontumi mfa keyboard 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 a ɛfa ankorankoro popovers ho
Wobetumi akyerɛ akwan foforo a wɔbɛfa so akyerɛ ankorankoro popovers 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 popover = new bootstrap.Popover(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ɔ hɔ ma element bi popover a wɔbɛda no adi no fi hɔ. Sɛ wɔsan de yɛ adwuma nkutoo a, wobetumi akyerɛ popover no. |
dispose |
Hides na ɛsɛe element bi popover (Eyi data a wɔde asie wɔ DOM element no so). Popovers a ɛde delegation di dwuma (a wɔbɔ denam option noselector so ) no ntumi nsɛe no ankorankoro wɔ descendant trigger elements so. |
enable |
Ɛma element bi popover tumi a wɔde bɛkyerɛ. Popovers no yɛ adwuma default so. |
getInstance |
Static kwan a ɛma wo kwan ma wo nya popover nhwɛso a ɛbata DOM element bi ho. |
getOrCreateInstance |
Static kwan a ɛma wo kwan ma wonya popover nhwɛso a ɛbata DOM element bi ho, anaasɛ wobɔ foforo sɛ ɛba sɛ wɔanhyɛ ase a. |
hide |
Fa element bi popover no sie. San kɔ nea ɔfrɛ no no nkyɛn ansa na wɔde popover no asie ankasa (kyerɛ sɛ ansa na hidden.bs.popover asɛm no asi). Wobu eyi sɛ “nsaano” a wɔde kanyan popover no. |
setContent |
Ɛma ɔkwan a wɔfa so sesa popover no mu nsɛm wɔ ne mfiase akyi. |
show |
Ɛda element bi popover adi. San kɔ nea ɔfrɛ no no nkyɛn ansa na wɔada popover no adi ankasa (kyerɛ sɛ ansa na shown.bs.popover asɛm no asi). Wobu eyi sɛ “nsaano” a wɔde kanyan popover no. Popovers a wɔn asɛmti ne emu nsɛm nyinaa yɛ zero-length no, wɔmfa nkyerɛ da. |
toggle |
Toggles element bi popover. San kɔ nea ɔfrɛ no no nkyɛn ansa na wɔakyerɛ popover no ankasa anaa wɔde asie (kyerɛ sɛ ansa na shown.bs.popover anaa hidden.bs.popover adeyɛ no aba). Wobu eyi sɛ “nsaano” a wɔde kanyan popover no. |
toggleEnabled |
Toggles tumi a ɛma element bi popover bɛkyerɛ anaa wɔde asie. |
update |
Updates gyinabea a element bi popover wɔ. |
// getOrCreateInstance example
const popover = bootstrap.Popover.getOrCreateInstance('#example') // Returns a Bootstrap popover instance
// setContent example
myPopover.setContent({
'.popover-header': 'another title',
'.popover-body': 'another content'
})
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.popover |
Wɔtow saa adeyɛ yi ntɛm ara bere a hide wɔafrɛ instance kwan no. |
hidden.bs.popover |
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.popover |
Wɔtow saa adeyɛ yi wɔ adeyɛ no akyi show.bs.popover bere a wɔde popover template no aka DOM no ho. |
show.bs.popover |
Saa adeyɛ yi tow ntɛm ara bere a show wɔfrɛ instance kwan no. |
shown.bs.popover |
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 myPopoverTrigger = document.getElementById('myPopover')
myPopoverTrigger.addEventListener('hidden.bs.popover', () => {
// do something...
})