Popovers
Cov ntaub ntawv thiab cov piv txwv rau ntxiv Bootstrap popovers, zoo li cov uas pom hauv iOS no, rau ib qho ntawm koj qhov chaw.
Txheej txheem cej luam
Tej yam uas yuav tsum paub thaum siv lub popover plugin:
- Popovers cia siab rau lub tsev qiv ntawv thib peb Popper rau qhov chaw. Koj yuav tsum suav nrog popper.min.js ua ntej
bootstrap.js
, lossis siv ib qhobootstrap.bundle.min.js
uas muaj Popper. - Popovers xav tau lub popover plugin ua qhov kev vam khom.
- Popovers yog opt-in rau kev ua tau zoo vim li cas, yog li koj yuav tsum pib lawv tus kheej .
- Zero-ntev
title
thiabcontent
qhov tseem ceeb yuav tsis pom qhov popover. - Qhia
container: 'body'
kom tsis txhob muaj teeb meem nyob rau hauv cov khoom siv ntau dua (xws li peb cov tswv yim pab pawg, pawg khawm, thiab lwm yam). - Triggering popovers ntawm cov ntsiab lus zais yuav tsis ua haujlwm.
- Popovers rau
.disabled
los yogdisabled
cov ntsiab lus yuav tsum tau ua rau ntawm cov khoom siv wrapper. - Thaum tshwm sim los ntawm cov thauj tog rau nkoj uas qhwv hla ntau kab, popovers yuav nyob nruab nrab ntawm cov thauj tog rau nkoj 'tag nrho dav. Siv
.text-nowrap
koj<a>
tus kheej kom tsis txhob muaj tus cwj pwm no. - Popovers yuav tsum tau muab zais ua ntej lawv cov ntsiab lus sib raug tau raug tshem tawm ntawm DOM.
- Popovers tuaj yeem tshwm sim ua tsaug rau ib qho hauv ib qho duab ntxoov ntxoo DOM.
prefers-reduced-motion
lus nug xov xwm. Saib qhov
txo qis ntawm peb cov ntaub ntawv nkag mus tau .
Khaws nyeem kom pom tias popovers ua haujlwm li cas nrog qee qhov piv txwv.
Piv txwv
Qhib popovers
Raws li tau hais los saum no, koj yuav tsum pib popovers ua ntej lawv tuaj yeem siv tau. Ib txoj hauv kev los pib tag nrho cov popovers ntawm nplooj ntawv yuav yog xaiv lawv los ntawm lawv cov data-bs-toggle
cwj pwm, xws li:
const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]')
const popoverList = [...popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl))
Nyob demo
Peb siv JavaScript zoo ib yam li cov snippet saum toj no los ua cov nram qab no nyob popover. Lub npe yog teem los ntawm data-bs-title
thiab lub cev cov ntsiab lus yog teem los ntawm data-bs-content
.
title
yog
data-bs-title
hauv koj li HTML. Thaum
title
siv, Popper yuav hloov nws nrog
data-bs-title
thaum lub caij ua tiav.
<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>
Plaub txoj kev
Muaj plaub txoj kev xaiv: sab saum toj, sab xis, hauv qab, thiab sab laug. Cov lus qhia tau mirrored thaum siv Bootstrap hauv RTL. Teem data-bs-placement
kom hloov cov kev taw qhia.
<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>
Kev caicontainer
Thaum koj muaj qee tus qauv ntawm niam txiv lub caij uas cuam tshuam nrog lub popover, koj yuav xav qhia qhov kev cai container
kom cov popover's HTML tshwm nyob rau hauv cov khoom ntawd. Qhov no tshwm sim hauv cov lus teb, pab pawg tswv yim, thiab lwm yam.
const popover = new bootstrap.Popover('.example-popover', {
container: 'body'
})
Lwm qhov xwm txheej uas koj yuav xav teeb tsa qhov kev cai tshwj container
xeeb yog popovers hauv kev sib tham modal , kom paub tseeb tias qhov popover nws tus kheej tau ntxiv rau lub modal. Qhov no yog qhov tseem ceeb tshwj xeeb tshaj yog rau cov popovers uas muaj cov ntsiab lus sib tham - modal dialogs yuav teeb tsom, yog li tshwj tsis yog lub popover yog ib qho me me ntawm cov modal, cov neeg siv yuav tsis tuaj yeem tsom lossis qhib cov ntsiab lus sib tham.
const popover = new bootstrap.Popover('.example-popover', {
container: '.modal-body'
})
Kev cai popovers
Ntxiv hauv v5.2.0Koj tuaj yeem kho qhov pom ntawm popovers siv CSS variables . Peb tau teeb tsa chav kawm kev cai nrog data-bs-custom-class="custom-popover"
kom muaj peev xwm ua tau raws li peb qhov kev cai thiab siv nws los hla qee qhov kev hloov pauv hauv CSS hauv zos.
.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>
Tshem tawm ntawm qhov nyem tom ntej
Siv qhov focus
ua kom tshem tawm cov popovers ntawm tus neeg siv tom ntej nyem ntawm ib lub caij sib txawv dua li qhov hloov pauv.
Cov cim tshwj xeeb xav tau rau kev tso tawm-ntawm-tom ntej-nias
Txhawm rau kom tus neeg siv khoom sib txawv thiab tus cwj pwm hla lub platform, koj yuav tsum siv lub <a>
cim npe, tsis yog lub <button>
cim, thiab koj kuj yuav tsum muaj tus tabindex
cwj pwm.
<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'
})
Cov neeg xiam oob qhab
Cov ntsiab lus nrog tus disabled
cwj pwm tsis sib cuam tshuam, txhais tau tias cov neeg siv tsis tuaj yeem txav los yog nyem rau lawv kom ua rau popover (lossis cov lus qhia). Raws li kev daws teeb meem, koj yuav xav ua kom lub popover los ntawm lub wrapper <div>
los yog <span>
, qhov zoo tshaj plaws ua keyboard-focusable siv tabindex="0"
.
Rau cov neeg xiam oob qhab popover tshwm sim, koj kuj xav tau data-bs-trigger="hover focus"
kom lub popover tshwm tam sim pom kev tawm tswv yim rau koj cov neeg siv vim lawv yuav tsis xav tias yuav nyem rau ntawm qhov chaw tsis taus.
<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
Hloov pauv
Ntxiv hauv v5.2.0Raws li ib feem ntawm Bootstrap qhov kev hloov pauv CSS hloov pauv mus kom ze, popovers tam sim no siv cov CSS hauv zos .popover
rau kev hloov kho lub sijhawm tiag tiag. Cov txiaj ntsig rau CSS qhov sib txawv tau teeb tsa ntawm Sass, yog li Sass customization tseem txhawb nqa, ib yam nkaus.
--#{$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 variables
$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;
Kev siv
Qhib popovers ntawm JavaScript:
const exampleEl = document.getElementById('example')
const popover = new bootstrap.Popover(exampleEl, options)
Ua popovers ua haujlwm rau cov keyboard thiab cov neeg siv thev naus laus zis
Txhawm rau tso cai rau cov neeg siv cov keyboard kom qhib koj cov popovers, koj tsuas yog yuav tsum ntxiv lawv rau HTML cov ntsiab lus uas ib txwm muaj cov keyboard-focusable thiab sib tham sib (xws li kev sib txuas lossis daim ntawv tswj). Txawm hais tias cov ntsiab lus HTML arbitrary (xws li <span>
s) tuaj yeem ua kom pom tseeb los ntawm kev ntxiv tus tabindex="0"
cwj pwm, qhov no yuav ntxiv qhov cuam tshuam thiab tsis meej pem tab nres ntawm cov ntsiab lus tsis sib tham rau cov neeg siv cov keyboard, thiab cov cuab yeej pabcuam feem ntau tam sim no tsis tshaj tawm cov ntsiab lus popover hauv qhov xwm txheej no. . Tsis tas li ntawd, tsis txhob cia siab ib leeg los hover
ua qhov ua rau koj cov popovers, vim qhov no yuav ua rau lawv tsis tuaj yeem ua rau cov neeg siv keyboard.
Thaum koj tuaj yeem ntxig cov nplua nuj, tsim HTML hauv popovers nrog kev html
xaiv, peb xav kom koj tsis txhob ntxiv cov ntsiab lus ntau dhau. Txoj kev popovers tam sim no ua haujlwm yog tias, ib zaug tso tawm, lawv cov ntsiab lus raug khi rau lub ntsiab lus nrog tus aria-describedby
cwj pwm. Raws li qhov tshwm sim, tag nrho ntawm cov ntsiab lus popover yuav raug tshaj tawm rau cov neeg siv thev naus laus zis ua ib qho ntev, tsis muaj kev cuam tshuam.
Tsis tas li ntawd, thaum nws tseem tuaj yeem suav nrog kev sib tham sib tswj (xws li cov ntsiab lus lossis cov ntawv txuas) hauv koj lub popover (los ntawm kev ntxiv cov ntsiab lus no rau allowList
ntawm cov khoom tso cai thiab cov cim npe), nco ntsoov tias tam sim no lub popover tsis tswj cov keyboard tsom xam xaj. Thaum tus neeg siv cov keyboard qhib lub popover, tsom mus rau qhov tshwm sim, thiab raws li qhov popover feem ntau tsis ua raws li qhov tshwm sim tam sim ntawd hauv cov ntaub ntawv tus qauv, tsis muaj kev lees paub tias mus tom ntej / nias.TAByuav txav tus neeg siv keyboard rau hauv popover nws tus kheej. Nyob rau hauv luv luv, tsuas yog ntxiv kev sib tham sib tswj rau ib tug popover yog yuav ua rau cov kev tswj tsis mus cuag / siv tsis tau rau cov neeg siv keyboard thiab cov neeg siv cov cuab yeej pab, los yog tsawg kawg yog ua rau ib tug illogical zuag qhia tag nrho kev txiav txim. Nyob rau hauv cov ntaub ntawv no, xav txog siv ib tug modal dialog xwb.
Kev xaiv
Raws li kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript, koj tuaj yeem ntxiv ib qho kev xaiv npe rau data-bs-
, xws li hauv data-bs-animation="{value}"
. Nco ntsoov hloov cov ntaub ntawv ntawm lub npe xaiv los ntawm " camelCase " mus rau " kebab-case " thaum dhau cov kev xaiv ntawm cov ntaub ntawv cwj pwm. Piv txwv li, siv data-bs-custom-class="beautifier"
es tsis txhob data-bs-customClass="beautifier"
.
Raws li ntawm Bootstrap 5.2.0, tag nrho cov khoom txhawb nqa qhov kev sim khaws tseg cov ntaub ntawv tus cwj pwm data-bs-config
uas tuaj yeem ua tsev yooj yim kev teeb tsa raws li JSON txoj hlua. Thaum ib qho khoom muaj data-bs-config='{"delay":0, "title":123}'
thiab data-bs-title="456"
tus cwj pwm, qhov kawg title
tus nqi yuav yog 456
thiab cov ntaub ntawv cais cov cwj pwm yuav override tus nqi muab rau data-bs-config
. Ntxiv mus, cov ntaub ntawv uas twb muaj lawm muaj peev xwm ua tsev JSON qhov tseem ceeb xws li data-bs-delay='{"show":0,"hide":150}'
.
sanitize
,
sanitizeFn
, thiab
allowList
cov kev xaiv tsis tuaj yeem muab siv cov ntaub ntawv tus cwj pwm.
Lub npe | Hom | Default | Kev piav qhia |
---|---|---|---|
allowList |
khoom | Default tus nqi | Yam khoom uas muaj cov cwj pwm tso cai thiab cov cim npe. |
animation |
boolean | true |
Siv CSS ploj mus rau qhov popover. |
boundary |
hlua, element | 'clippingParents' |
Overflow txwv ciam teb ntawm lub popover (tsuas yog siv rau Popper's PreventOverflow modifier). Los ntawm lub neej ntawd, nws yog 'clippingParents' thiab tuaj yeem lees txais HTMLElement siv (ntawm JavaScript nkaus xwb). Yog xav paub ntxiv mus saib Popper's detectOverflow docs . |
container |
hlua, element, cuav | false |
Appends lub popover rau ib yam khoom. container: 'body' Piv txwv :. Qhov kev xaiv no yog qhov tshwj xeeb tshaj yog nyob rau hauv uas nws tso cai rau koj tso lub popover nyob rau hauv lub ntws ntawm cov ntaub ntawv nyob ze ntawm lub triggering caij - uas yuav tiv thaiv lub popover los ntawm ntab deb ntawm lub triggering lub sij hawm thaum lub qhov rais resize. |
content |
hlua, element, function | '' |
Default ntsiab lus tus nqi yog data-bs-content attribute tsis nyob. Yog tias muaj nuj nqi tau muab, nws yuav raug hu nrog nws cov this ntaub ntawv teev rau lub caij uas lub popover txuas nrog. |
customClass |
txoj hlua, ua haujlwm | '' |
Ntxiv cov chav kawm rau lub popover thaum nws pom. Nco ntsoov tias cov chav kawm no yuav muab ntxiv ntxiv rau cov chav kawm uas tau teev tseg hauv cov qauv. Txhawm rau ntxiv ntau chav kawm, cais lawv nrog qhov chaw: 'class-1 class-2' . Koj tuaj yeem dhau ib txoj haujlwm uas yuav tsum rov qab ib txoj hlua uas muaj cov npe hauv chav kawm ntxiv. |
delay |
tus lej, yam khoom | 0 |
Ncua sijhawm qhia thiab zais qhov popover (ms) - tsis siv rau phau ntawv txhais hom. Yog tias muaj tus lej nkag, ncua sijhawm yog siv rau ob qho tib si zais / qhia. Yam khoom qauv yog: delay: { "show": 500, "hide": 100 } . |
fallbackPlacements |
hlua, array | ['top', 'right', 'bottom', 'left'] |
Txheeb xyuas qhov chaw rov qab los ntawm kev muab cov npe ntawm qhov chaw nyob hauv array (hauv kev txiav txim siab). Yog xav paub ntxiv mus saib Popper tus cwj pwm docs . |
html |
boolean | false |
Cia HTML nyob rau hauv lub popover. Yog tias muaj tseeb, HTML cim npe hauv popover's title yuav raug muab tso rau hauv popover. Yog tias tsis tseeb, innerText cov cuab yeej yuav raug siv los ntxig cov ntsiab lus rau hauv DOM. Siv cov ntawv nyeem yog tias koj txhawj xeeb txog XSS tawm tsam. |
offset |
tooj, hlua, muaj nuj nqi | [0, 0] |
Offset ntawm popover txheeb ze rau nws lub hom phiaj. Koj tuaj yeem hla ib txoj hlua hauv cov ntaub ntawv tus cwj pwm nrog comma cais qhov tseem ceeb xws li: data-bs-offset="10,20" . Thaum muaj nuj nqi yog siv los txiav txim qhov offset, nws raug hu nrog ib yam khoom uas muaj cov popper qhov chaw, siv, thiab popper rects raws li nws thawj qhov kev sib cav. Lub triggering element DOM node tau dhau los ua qhov kev sib cav thib ob. Txoj haujlwm yuav tsum rov qab ib qho array nrog ob tus lej: skidding , nrug . Yog xav paub ntxiv mus saib Popper's offset docs . |
placement |
txoj hlua, ua haujlwm | 'top' |
Yuav ua li cas tso lub popover: pib, sab saum toj, hauv qab, sab laug, sab xis. Thaum auto tau teev tseg, nws yuav dynamically reorient lub popover. Thaum muaj nuj nqi yog siv los txiav txim qhov kev tso kawm, nws raug hu nrog popover DOM node raws li nws thawj qhov kev sib cav thiab lub triggering ntsiab DOM node raws li nws thib ob. Cov this ntsiab lus tau teeb tsa rau qhov piv txwv popover. |
popperConfig |
null, object, function | null |
Txhawm rau hloov Bootstrap's default Popper config, saib Popper's configuration . Thaum muaj nuj nqi siv los tsim Popper teeb tsa, nws tau hu nrog ib qho khoom uas muaj Bootstrap's default Popper configuration. Nws pab koj siv thiab ua ke lub neej ntawd nrog koj tus kheej configuration. Cov haujlwm yuav tsum xa rov qab cov khoom teeb tsa rau Popper. |
sanitize |
boolean | true |
Qhib lossis kaw qhov kev huv huv. Yog tias qhib 'template' , 'content' thiab 'title' cov kev xaiv yuav raug ntxuav. |
sanitizeFn |
null, ua | null |
Ntawm no koj tuaj yeem muab koj tus kheej ua haujlwm huv. Qhov no tuaj yeem pab tau yog tias koj xav siv lub tsev qiv ntawv tshwj xeeb los ua kom huv. |
selector |
txoj hlua, cuav | false |
Yog tias muaj ib tus neeg xaiv tau muab, cov khoom popover yuav raug xa mus rau cov phiaj xwm tshwj xeeb. Hauv kev xyaum, qhov no yog siv los kuj siv popovers rau dynamically ntxiv DOM ntsiab ( jQuery.on kev txhawb nqa). Saib qhov teeb meem no thiab ib qho piv txwv qhia . |
template |
txoj hlua | '<div class="popover" role="popover"><div class="popover-arrow"></div><div class="popover-inner"></div></div>' |
Base HTML siv thaum tsim cov popover. Popover's title yuav raug txhaj rau hauv .popover-inner . .popover-arrow yuav dhau los ua tus popover tus xub. Cov txheej txheem wrapper sab nraud yuav tsum muaj cov .popover chav kawm thiab role="popover" . |
title |
hlua, element, function | '' |
Default title value yog title attribute tsis nyob. Yog tias muaj nuj nqi tau muab, nws yuav raug hu nrog nws cov this ntaub ntawv teev rau lub caij uas lub popover txuas nrog. |
trigger |
txoj hlua | 'hover focus' |
Yuav ua li cas popover yog triggered: nyem, hover, tsom, phau ntawv. Koj tuaj yeem hla ntau qhov ua rau; cais lawv nrog ib qho chaw. 'manual' qhia tau hais tias lub popover yuav tau triggered programmatically ntawm lub .popover('show') , .popover('hide') thiab .popover('toggle') txoj kev; tus nqi no tsis tuaj yeem ua ke nrog lwm qhov kev cuam tshuam. 'hover' ntawm nws tus kheej yuav ua rau popovers uas tsis tuaj yeem tshwm sim ntawm cov keyboard, thiab tsuas yog yuav tsum tau siv yog tias lwm txoj hauv kev xa cov ntaub ntawv tib yam rau cov neeg siv cov keyboard tam sim no. |
Cov ntaub ntawv tus cwj pwm rau tus kheej popovers
Kev xaiv rau ib tus neeg popovers tuaj yeem hloov tau los ntawm kev siv cov ntaub ntawv tus cwj pwm, raws li tau piav qhia saum toj no.
Siv ua haujlwm nrogpopperConfig
const popover = new bootstrap.Popover(element, {
popperConfig(defaultBsPopperConfig) {
// const newPopperConfig = {...}
// use defaultBsPopperConfig if needed...
// return newPopperConfig
}
})
Cov txheej txheem
Asynchronous txoj kev thiab kev hloov
Txhua txoj kev API yog asynchronous thiab pib hloov pauv . Lawv rov qab mus rau tus neeg hu xov tooj sai li sai tau thaum qhov kev hloov pauv pib tab sis ua ntej nws xaus . Tsis tas li ntawd, ib txoj kev hu rau kev hloov pauv yuav raug tsis quav ntsej .
Txoj kev | Kev piav qhia |
---|---|
disable |
Tshem tawm lub peev xwm rau lub ntsiab lus popover kom pom. Lub popover tsuas tuaj yeem pom yog tias nws rov qhib dua. |
dispose |
Nkaum thiab rhuav tshem lub ntsiab lus popover (Tshem cov ntaub ntawv khaws cia ntawm DOM lub caij). Popovers uas siv delegation (uas yog tsim los ntawm selector kev xaiv ) tsis tuaj yeem raug rhuav tshem ib tus zuj zus ntawm cov xeeb leej xeeb ntxwv. |
enable |
Muab ib qho khoom popover lub peev xwm los qhia. Popovers tau qhib los ntawm lub neej ntawd. |
getInstance |
Txoj kev zoo li qub uas tso cai rau koj kom tau txais qhov piv txwv popover txuam nrog DOM keeb. |
getOrCreateInstance |
Txoj kev zoo li qub uas tso cai rau koj kom tau txais qhov piv txwv popover txuam nrog DOM lub caij, lossis tsim ib qho tshiab yog tias nws tsis tau pib. |
hide |
Hide ib lub ntsiab lus popover. Rov qab mus rau tus neeg hu ua ntej qhov popover tau muab zais tiag tiag (piv txwv li ua ntej qhov hidden.bs.popover xwm txheej tshwm sim). Qhov no suav hais tias yog "kev tuav tswj" ua rau lub popover. |
setContent |
Muab ib txoj hauv kev los hloov cov ntsiab lus popover tom qab nws pib. |
show |
Qhia ib lub ntsiab lus popover. Rov qab mus rau tus neeg hu ua ntej qhov popover tau tshwm sim tiag tiag (piv txwv li ua ntej qhov shown.bs.popover xwm txheej tshwm sim). Qhov no suav hais tias yog "kev tuav tswj" ua rau lub popover. Popovers uas nws lub npe thiab cov ntsiab lus yog xoom-ntev tsis tau tshwm sim. |
toggle |
Toggles ib lub ntsiab lus popover. Rov qab mus rau tus neeg hu ua ntej lub popover tau tshwm sim los yog zais (piv txwv li ua ntej qhov shown.bs.popover kev hidden.bs.popover tshwm sim tshwm sim). Qhov no suav hais tias yog "kev tuav tswj" ua rau lub popover. |
toggleEnabled |
Toggles lub peev xwm rau lub ntsiab lub popover kom pom los yog zais. |
update |
Hloov tshiab txoj hauj lwm ntawm lub ntsiab lub popover. |
// 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
kev lees txais qhov kev
object
sib cav, qhov twg txhua lub cuab yeej-tus yuam sij yog tus
string
xaiv siv tau nyob rau hauv cov qauv popover, thiab txhua yam khoom muaj nqis tuaj yeem ua tau
string
|
element
|
function
|
null
Cov xwm txheej
Kev tshwm sim | Kev piav qhia |
---|---|
hide.bs.popover |
Qhov xwm txheej no raug rho tawm haujlwm tam sim ntawd thaum hide hu ua piv txwv txoj kev. |
hidden.bs.popover |
Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub popover tiav lawm muab zais los ntawm tus neeg siv (yuav tos rau CSS kev hloov pauv kom tiav). |
inserted.bs.popover |
Qhov kev tshwm sim no raug rho tawm haujlwm tom qab qhov show.bs.popover tshwm sim thaum lub popover template tau ntxiv rau DOM. |
show.bs.popover |
Qhov xwm txheej no tua hluav taws tam sim ntawd thaum show hu ua piv txwv. |
shown.bs.popover |
Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub popover tau pom rau tus neeg siv (yuav tos rau CSS kev hloov pauv kom tiav). |
const myPopoverTrigger = document.getElementById('myPopover')
myPopoverTrigger.addEventListener('hidden.bs.popover', () => {
// do something...
})