Popovers
Iwe ati awọn apẹẹrẹ fun fifi awọn agbejade Bootstrap kun, bii awọn ti a rii ni iOS, si eyikeyi eroja lori aaye rẹ.
Akopọ
Awọn nkan lati mọ nigba lilo ohun itanna popover:
- Popovers gbarale ile-ikawe ẹnikẹta Popper fun ipo. O gbọdọ ni popper.min.js ṣaaju
bootstrap.js
, tabi lo ọkanbootstrap.bundle.min.js
ti o ni Popper ninu. - Popovers nilo ohun itanna agbejade bi igbẹkẹle kan.
- Popovers ti yọkuro fun awọn idi iṣẹ ṣiṣe, nitorinaa o gbọdọ ṣe ipilẹṣẹ wọn funrararẹ .
- Gigun odo
title
aticontent
awọn iye kii yoo ṣe afihan agbejade kan. - Pato
container: 'body'
lati yago fun awọn iṣoro ṣiṣe ni awọn paati eka diẹ sii (bii awọn ẹgbẹ titẹ sii, awọn ẹgbẹ bọtini, ati bẹbẹ lọ). - Nfa popovers lori awọn eroja ti o farapamọ kii yoo ṣiṣẹ.
- Popovers fun
.disabled
tabidisabled
eroja gbọdọ wa ni jeki on a wrapper ano. - Nigbati o ba fa lati awọn ìdákọró ti o fi ipari si awọn laini pupọ, awọn popovers yoo wa ni aarin laarin iwọn apapọ awọn ìdákọró. Lo
.text-nowrap
lori rẹ<a>
s lati yago fun yi ihuwasi. - Popovers gbọdọ wa ni pamọ ṣaaju ki o to yọkuro awọn eroja ti o baamu wọn lati DOM.
- Popovers le ti wa ni jeki ọpẹ si ohun ano inu a ojiji DOM.
prefers-reduced-motion
ibeere media. Wo
apakan išipopada ti o dinku ti iwe iraye si wa .
Jeki kika lati wo bi awọn popovers ṣe n ṣiṣẹ pẹlu awọn apẹẹrẹ diẹ.
Awọn apẹẹrẹ
Mu popovers ṣiṣẹ
Gẹgẹbi a ti sọ loke, o gbọdọ ṣe ipilẹṣẹ popovers ṣaaju ki wọn le ṣee lo. Ọna kan lati bẹrẹ gbogbo awọn agbejade lori oju-iwe kan yoo jẹ lati yan wọn nipasẹ data-bs-toggle
ẹda wọn, bii bẹ:
const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]')
const popoverList = [...popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl))
Live demo
A lo JavaScript ti o jọra si snippet loke lati ṣe agbejade ifiwe laaye atẹle. Awọn akọle ti ṣeto nipasẹ data-bs-title
ati akoonu ara ti ṣeto nipasẹ data-bs-content
.
title
tabi
data-bs-title
ni HTML rẹ. Nigbati
title
o ba lo, Popper yoo paarọ rẹ laifọwọyi pẹlu
data-bs-title
nigbati a ba ṣe eroja naa.
<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>
Awọn itọnisọna mẹrin
Awọn aṣayan mẹrin wa: oke, ọtun, isalẹ, ati osi. Awọn itọnisọna jẹ digi nigba lilo Bootstrap ni RTL. Ṣeto data-bs-placement
lati yi itọsọna naa pada.
<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>
Aṣacontainer
Nigba ti o ba ni diẹ ninu awọn aza lori kan obi ano ti o dabaru pẹlu a popover, o yoo fẹ lati pato kan aṣa container
ki HTML popover han laarin ti ano dipo. Eyi jẹ wọpọ ni awọn tabili idahun, awọn ẹgbẹ titẹ sii, ati bii.
const popover = new bootstrap.Popover('.example-popover', {
container: 'body'
})
Ipo miiran nibiti iwọ yoo fẹ lati ṣeto aṣa ti o fojuhan container
jẹ awọn agbejade inu a modal dialog , lati rii daju pe agbejade funrararẹ ti wa ni afikun si modal. Eyi ṣe pataki ni pataki fun awọn agbejade ti o ni awọn eroja ibaraenisepo – awọn ibaraẹnisọrọ modal yoo dẹkun idojukọ, nitorinaa ayafi ti popover jẹ ẹya ọmọ ti modal, awọn olumulo kii yoo ni anfani si idojukọ tabi mu awọn eroja ibaraenisepo ṣiṣẹ.
const popover = new bootstrap.Popover('.example-popover', {
container: '.modal-body'
})
Aṣa popovers
Fi kun v5.2.0O le ṣe akanṣe irisi popovers nipa lilo awọn oniyipada CSS . A ṣeto kilasi aṣa kan pẹlu data-bs-custom-class="custom-popover"
lati ṣe iwọn irisi aṣa wa ati lo lati bori diẹ ninu awọn oniyipada CSS agbegbe.
.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>
Yọọ kuro ni titẹ atẹle
Lo focus
okunfa lati yọ awọn popovers kuro lori titẹ atẹle olumulo ti nkan ti o yatọ ju ano toggle.
Siṣamisi kan pato nilo fun yiyọ kuro-lori-tẹle
Fun aṣawakiri agbelebu ti o tọ ati ihuwasi Syeed, o gbọdọ lo <a>
tag, kii ṣe tag <button>
, ati pe o tun gbọdọ ni abuda kan tabindex
.
<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'
})
Awọn eroja alaabo
Awọn eroja pẹlu disabled
ẹya kii ṣe ibaraenisepo, afipamo pe awọn olumulo ko le rababa tabi tẹ wọn lati ṣe okunfa agbejade (tabi ohun elo irinṣẹ). Gẹgẹbi iṣẹ-ṣiṣe, iwọ yoo fẹ lati ma ṣe okunfa popover lati inu iwe-ipamọ <div>
tabi <span>
, ti a ṣe ni aifọwọyi-idojukọ keyboard nipa lilo tabindex="0"
.
Fun awọn okunfa popover alaabo, o tun le fẹ data-bs-trigger="hover focus"
ki popover naa han bi esi wiwo lẹsẹkẹsẹ si awọn olumulo rẹ nitori wọn le ma nireti lati tẹ lori nkan alaabo kan.
<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
Awọn oniyipada
Fi kun v5.2.0Gẹ́gẹ́ bí ara Bootstrap’s títúnṣe àwọn oníyípadà CSS, àwọn àgbéjáde ń lo àwọn oniyipada CSS ti agbegbe .popover
fun imudara isọdi-akoko gidi. Awọn iye fun awọn oniyipada CSS ti ṣeto nipasẹ Sass, nitorinaa isọdi Sass tun ni atilẹyin, paapaa.
--#{$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 oniyipada
$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;
Lilo
Mu awọn agbejade ṣiṣẹ nipasẹ JavaScript:
const exampleEl = document.getElementById('example')
const popover = new bootstrap.Popover(exampleEl, options)
Ṣiṣe popovers ṣiṣẹ fun keyboard ati awọn olumulo imọ-ẹrọ iranlọwọ
Lati gba awọn olumulo keyboard laaye lati mu awọn agbejade rẹ ṣiṣẹ, o yẹ ki o ṣafikun wọn nikan si awọn eroja HTML ti o jẹ aifọwọyi ti aṣa ati ibaraenisọrọ (gẹgẹbi awọn ọna asopọ tabi awọn idari fọọmu). Botilẹjẹpe awọn eroja HTML lainidii (gẹgẹbi awọn <span>
s) le jẹ ki o ni idojukọ nipa fifi tabindex="0"
ẹda naa kun, eyi yoo ṣafikun awọn iduro didanubi ati idamu lori awọn eroja ti kii ṣe ibaraenisepo fun awọn olumulo keyboard, ati ọpọlọpọ awọn imọ-ẹrọ iranlọwọ lọwọlọwọ ko kede akoonu popover ni ipo yii. . Ni afikun, maṣe gbarale hover
bi okunfa fun awọn agbejade rẹ, nitori eyi yoo jẹ ki wọn ko ṣee ṣe lati ma ṣe okunfa fun awọn olumulo keyboard.
Lakoko ti o le fi ọrọ sii, HTML ti iṣeto ni awọn agbejade pẹlu html
aṣayan, a ṣeduro ni iyanju pe ki o yago fun fifi iye akoonu ti o pọ ju. Awọn ọna popovers Lọwọlọwọ ṣiṣẹ ni wipe, ni kete ti han, wọn akoonu ti wa ni ti so si awọn okunfa ano pẹlu awọn aria-describedby
ro pe. Bi abajade, gbogbo akoonu popover ni yoo kede si awọn olumulo imọ-ẹrọ iranlọwọ bi ṣiṣan gigun kan, ṣiṣan ti ko ni idilọwọ.
Ni afikun, lakoko ti o ṣee ṣe lati tun pẹlu awọn iṣakoso ibaraenisepo (gẹgẹbi awọn eroja fọọmu tabi awọn ọna asopọ) ninu agbejade rẹ (nipa fifi awọn eroja wọnyi kun awọn abuda allowList
ti a gba laaye ati awọn afi), ṣe akiyesi pe lọwọlọwọ popover ko ṣakoso aṣẹ idojukọ keyboard. Nigbati olumulo keyboard ba ṣii agbejade kan, idojukọ wa lori nkan ti o nfa, ati pe bi popover nigbagbogbo ko ṣe tẹle okunfa lẹsẹkẹsẹ ninu eto iwe, ko si iṣeduro pe gbigbe siwaju / titẹTAByoo gbe olumulo keyboard sinu popover funrararẹ. Ni kukuru, fifi awọn iṣakoso ibaraenisepo pọ si agbejade kan ṣee ṣe lati jẹ ki awọn idari wọnyi ko ṣee de / ko ṣee ṣe fun awọn olumulo keyboard ati awọn olumulo ti awọn imọ-ẹrọ iranlọwọ, tabi ni o kere pupọ ṣe fun aṣẹ idojukọ gbogbogbo ti ko logbon. Ni awọn iṣẹlẹ wọnyi, ronu nipa lilo ibaraẹnisọrọ modal dipo.
Awọn aṣayan
Bi awọn aṣayan ṣe le kọja nipasẹ awọn abuda data tabi JavaScript, o le fi orukọ aṣayan si data-bs-
, bi ninu data-bs-animation="{value}"
. Rii daju lati yi iru ọran ti orukọ aṣayan pada lati “ CamelCase ” si “ kebab-case ” nigba gbigbe awọn aṣayan nipasẹ awọn abuda data. Fun apẹẹrẹ, lo data-bs-custom-class="beautifier"
dipo data-bs-customClass="beautifier"
.
Bi ti Bootstrap 5.2.0, gbogbo awọn paati ṣe atilẹyin abuda data ipamọ idanwodata-bs-config
ti o le ṣe atunto paati ti o rọrun bi okun JSON kan. Nigbati ohun kan ba ni data-bs-config='{"delay":0, "title":123}'
ati data-bs-title="456"
awọn abuda, iye ikẹhin title
yoo jẹ 456
ati awọn abuda data lọtọ yoo dojuti awọn iye ti a fun lori data-bs-config
. Ni afikun, awọn abuda data ti o wa ni anfani lati gbe awọn iye JSON bii data-bs-delay='{"show":0,"hide":150}'
.
sanitize
,
sanitizeFn
, ati
allowList
awọn aṣayan ko ṣe pese pẹlu awọn abuda data.
Oruko | Iru | Aiyipada | Apejuwe |
---|---|---|---|
allowList |
nkan | Iwọn aiyipada | Nkan ti o ni awọn abuda ti a gba laaye ati awọn afi. |
animation |
boolian | true |
Waye iyipada ipare CSS kan si agbejade. |
boundary |
okun, ano | 'clippingParents' |
Ààlà ìjánu àkúnwọ́sílẹ̀ ti popover (kan nikan si Popper ká preventOverflow modifier). Nipa aiyipada, o jẹ 'clippingParents' ati pe o le gba itọkasi HTMLElement (nipasẹ JavaScript nikan). Fun alaye diẹ sii tọka si Popper's detectOverflow docs . |
container |
okun, ano, eke | false |
Ṣafikun popover si nkan kan pato. Apeere container: 'body' :. Aṣayan yii wulo paapaa ni pe o fun ọ laaye lati gbe agbejade ni ṣiṣan ti iwe-ipamọ nitosi nkan ti o nfa - eyiti yoo ṣe idiwọ agbejade lati lilefoofo kuro ni nkan ti o nfa lakoko iwọn window kan. |
content |
okun, ano, iṣẹ | '' |
Iwọn akoonu aiyipada ti data-bs-content abuda ko ba si. Ti iṣẹ kan ba fun, yoo pe pẹlu this itọkasi ti a ṣeto si nkan ti a so popover si. |
customClass |
okun, iṣẹ | '' |
Fi awọn kilasi kun popover nigbati o ba han. Ṣe akiyesi pe awọn kilasi wọnyi yoo ṣafikun ni afikun si eyikeyi awọn kilasi pato ninu awoṣe. Lati ṣafikun awọn kilasi pupọ, ya wọn sọtọ pẹlu awọn alafo 'class-1 class-2' :. O tun le ṣe iṣẹ kan ti o yẹ ki o da okun kan pada ti o ni awọn orukọ kilasi afikun ninu. |
delay |
nọmba, ohun | 0 |
Idaduro iṣafihan ati fifipamo popover (ms) — ko kan si iru okunfa afọwọṣe. Ti nọmba kan ba pese, idaduro jẹ lilo si tọju/fihan mejeeji. delay: { "show": 500, "hide": 100 } Ilana nkan jẹ :. |
fallbackPlacements |
okun, orun | ['top', 'right', 'bottom', 'left'] |
Ṣetumo awọn ibi ifẹhinti nipa pipese atokọ ti awọn ipo ni titobi (ni aṣẹ ti o fẹ). Fun alaye diẹ sii tọka si awọn iwe aṣẹ ihuwasi Popper . |
html |
boolian | false |
Gba HTML laaye ni agbejade. Ti o ba jẹ otitọ, awọn aami HTML ni popover's title yoo ṣe ni agbejade. Ti o ba jẹ eke, innerText ohun-ini yoo ṣee lo lati fi akoonu sii sinu DOM. Lo ọrọ ti o ba ni aniyan nipa awọn ikọlu XSS. |
offset |
nọmba, okun, iṣẹ | [0, 0] |
Aiṣedeede ti popover ni ibatan si ibi-afẹde rẹ. O le kọja okun kan ninu awọn abuda data pẹlu awọn iye ti o ya sọtọ komama bii: data-bs-offset="10,20" . Nigba ti a ba lo iṣẹ kan lati pinnu aiṣedeede, a npe ni pẹlu ohun ti o ni ibi-popper, itọkasi, ati popper rects bi ariyanjiyan akọkọ rẹ. Ipin DOM ti o nfa ti kọja bi ariyanjiyan keji. Iṣẹ naa gbọdọ da opo kan pada pẹlu awọn nọmba meji: skidding , ijinna . Fun alaye diẹ sii tọka si awọn iwe aiṣedeede Popper . |
placement |
okun, iṣẹ | 'top' |
Bii o ṣe le gbe agbejade: adaṣe, oke, isalẹ, osi, ọtun. Nigba ti o ba auto wa ni pato, yoo ṣe atunto agbejade naa lainidi. Nigbati a ba lo iṣẹ kan lati pinnu ipo, o pe pẹlu agbejade DOM agbejade bi ariyanjiyan akọkọ rẹ ati node DOM ti o nfa bi keji rẹ. A this ti ṣeto ọrọ-ọrọ si apẹẹrẹ popover. |
popperConfig |
asan, ohun, iṣẹ | null |
Lati yi Bootstrap aiyipada atunto Popper pada, wo iṣeto Popper . Nigbati a ba lo iṣẹ kan lati ṣẹda iṣeto Popper, o pe pẹlu ohun kan ti o ni iṣeto ni aiyipada Bootstrap. O ṣe iranlọwọ fun ọ lati lo ati dapọ aiyipada pẹlu iṣeto ni tirẹ. Iṣẹ naa gbọdọ da ohun atunto pada fun Popper. |
sanitize |
boolian | true |
Muu ṣiṣẹ tabi mu isọdọmọ kuro. Ti o ba muu ṣiṣẹ 'template' , 'content' ati 'title' awọn aṣayan yoo di mimọ. |
sanitizeFn |
asan, iṣẹ | null |
Nibi o le pese iṣẹ imototo tirẹ. Eyi le wulo ti o ba fẹ lati lo ile-ikawe iyasọtọ lati ṣe imototo. |
selector |
okun, eke | false |
Ti o ba ti pese oluyan, awọn ohun agbejade yoo jẹ aṣoju si awọn ibi-afẹde ti a pato. Ni iṣe, eyi ni a lo lati tun lo awọn agbejade si awọn eroja DOM ti a ṣafikun ni agbara ( jQuery.on atilẹyin). Wo atejade yii ati apẹẹrẹ alaye . |
template |
okun | '<div class="popover" role="popover"><div class="popover-arrow"></div><div class="popover-inner"></div></div>' |
HTML mimọ lati lo nigba ṣiṣẹda popover. Awọn popover's title yoo jẹ itasi sinu .popover-inner . .popover-arrow yoo di ofa popover. Apo-apa- apo ti ita julọ yẹ ki o ni .popover kilasi ati role="popover" . |
title |
okun, ano, iṣẹ | '' |
Iwọn akọle aiyipada ti title ẹda ko ba si. Ti iṣẹ kan ba fun, yoo pe pẹlu this itọkasi ti a ṣeto si nkan ti a so popover si. |
trigger |
okun | 'hover focus' |
Bawo ni popover ti wa ni jeki: tẹ, rababa, idojukọ, Afowoyi. O le ṣe ọpọlọpọ awọn okunfa; ya wọn pẹlu aaye kan. 'manual' tọkasi wipe popover yoo wa ni jeki programmatically nipasẹ awọn .popover('show') , .popover('hide') ati .popover('toggle') awọn ọna; yi iye ko le wa ni idapo pelu eyikeyi miiran okunfa. 'hover' lori ara rẹ yoo ja si awọn popovers ti ko le ṣe okunfa nipasẹ keyboard, ati pe o yẹ ki o lo nikan ti awọn ọna omiiran fun gbigbe alaye kanna fun awọn olumulo keyboard wa. |
Data eroja fun olukuluku popovers
Awọn aṣayan fun awọn agbejade kọọkan le jẹ iyasọtọ nipasẹ lilo awọn abuda data, bi a ti salaye loke.
Lilo iṣẹ pẹlupopperConfig
const popover = new bootstrap.Popover(element, {
popperConfig(defaultBsPopperConfig) {
// const newPopperConfig = {...}
// use defaultBsPopperConfig if needed...
// return newPopperConfig
}
})
Awọn ọna
Awọn ọna Asynchronous ati awọn iyipada
Gbogbo awọn ọna API jẹ asynchronous ati bẹrẹ iyipada kan . Wọn pada si ọdọ olupe ni kete ti iyipada ti bẹrẹ ṣugbọn ṣaaju ki o to pari . Ni afikun, ipe ọna kan lori paati iyipada yoo jẹ kọbikita .
Ọna | Apejuwe |
---|---|
disable |
Yọ awọn agbara fun ohun ano ká popover lati han. Agbejade naa yoo ni anfani lati han nikan ti o ba tun ṣiṣẹ. |
dispose |
Ìbòmọlẹ ati ki o run ohun ano ká popover (Yọ awọn ti o ti fipamọ data lori DOM ano). Popovers ti o lo aṣoju (eyi ti a ṣẹda nipa lilo aṣayan ) selector ko le ṣe iparun ni ẹyọkan lori awọn eroja ti o nfa ọmọ. |
enable |
Yoo fun ohun ano ká popover ni agbara lati han. Popovers ti ṣiṣẹ nipasẹ aiyipada. |
getInstance |
Ọna aimi eyiti o fun ọ laaye lati gba apẹẹrẹ popover ti o ni nkan ṣe pẹlu nkan DOM kan. |
getOrCreateInstance |
Ọna aimi eyiti o fun ọ laaye lati gba apẹẹrẹ popover ti o ni nkan ṣe pẹlu nkan DOM kan, tabi ṣẹda ọkan tuntun ti ko ba ṣe ipilẹṣẹ. |
hide |
Ìbòmọlẹ ohun ano ká popover. Pada si olupe ṣaaju ki agbejade ti farapamọ gangan (ie ṣaaju ki hidden.bs.popover iṣẹlẹ naa to waye). Eyi ni a kà si “afọwọṣe” ti nfa popover. |
setContent |
O funni ni ọna lati yi akoonu popover pada lẹhin ipilẹṣẹ rẹ. |
show |
Ṣe afihan agbejade ano kan. Pada si olupe ṣaaju ki agbejade ti han gangan (ie ṣaaju ki shown.bs.popover iṣẹlẹ naa to waye). Eyi ni a kà si “afọwọṣe” ti nfa popover. Popovers ti akọle ati akoonu mejeeji jẹ gigun odo ko han rara. |
toggle |
Yipada ohun ano ká popover. Pada si olupe ṣaaju ki agbejade ti han gangan tabi farapamọ (ie ṣaaju ki iṣẹlẹ shown.bs.popover tabi hidden.bs.popover iṣẹlẹ to waye). Eyi ni a kà si “afọwọṣe” ti nfa popover. |
toggleEnabled |
Yipada agbara fun agbejade eroja lati han tabi pamọ. |
update |
Ṣe imudojuiwọn ipo agbejade eroja kan. |
// 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
gba
object
ariyanjiyan kan, nibiti bọtini ohun-ini kọọkan jẹ yiyan ti o wulo
string
laarin awoṣe popover, ati iye-ini ohun-ini kọọkan ti o ni ibatan le jẹ
string
|
element
|
function
|
null
Awọn iṣẹlẹ
Iṣẹlẹ | Apejuwe |
---|---|
hide.bs.popover |
Iṣẹlẹ yii jẹ ina lẹsẹkẹsẹ nigbati ọna hide apẹẹrẹ ti pe. |
hidden.bs.popover |
Iṣẹlẹ yii jẹ ina nigbati agbejade ba ti pari fifipamọ lati ọdọ olumulo (yoo duro fun awọn iyipada CSS lati pari). |
inserted.bs.popover |
Iṣẹlẹ yii jẹ ina lẹhin show.bs.popover iṣẹlẹ naa nigbati a ti ṣafikun awoṣe popover si DOM. |
show.bs.popover |
Yi iṣẹlẹ ina lẹsẹkẹsẹ nigbati awọn show apẹẹrẹ ọna ti a npe ni. |
shown.bs.popover |
Iṣẹlẹ yii jẹ ina nigbati popover ti jẹ ki o han si olumulo (yoo duro fun awọn iyipada CSS lati pari). |
const myPopoverTrigger = document.getElementById('myPopover')
myPopoverTrigger.addEventListener('hidden.bs.popover', () => {
// do something...
})