Tlula eka nhlokomhaka-nkulu Tlula eka docs navigation
Check
in English

Popovers

Matsalwa na swikombiso swo engetela ti-popover ta Bootstrap, ku fana na leti kumekaka eka iOS, eka elemente yihi na yihi eka sayiti ya wena.

Nkatsakanyo

Swilo leswi u faneleke u swi tiva loko u tirhisa plugin ya popover:

  • Popovers yi titshege hi layiburari ya munhu wa vunharhu Popper eka xiyimo. U fanele ku katsa popper.min.js emahlweni ka bootstrap.js, kutani u tirhisa bootstrap.bundle.min.jsleyi nga na Popper.
  • Popovers yi lava popover plugin tanihi ku titshega.
  • Ti-popovers i ti-opt-in hikwalaho ka swivangelo swa matirhelo, hikwalaho u fanele u ti sungula hi wexe .
  • Zero-length titlena contentvalues ​​a swi nge pfuki swi kombisi popover.
  • Boxa container: 'body'ku papalata swiphiqo swa ku hundzuluxela eka swiphemu leswi rharhanganeke swinene (ku fana na mintlawa ya hina ya ku nghenisa, mintlawa ya swikomba-nkarhi, na swin’wana).
  • Ku hlohlotela ti-popovers eka swiaki leswi fihliweke a swi nge tirhi.
  • Popovers for .disabledkumbe disabledti elements tifanele ku pfuriwa eka element ya wrapper.
  • Loko yi hlohleteriwa kusuka eka ti anchors leti phutselaka eka milayeni yotala, ti popovers titava tiri exikarhi exikarhi ka ku anama hinkwako ka ti anchors. Tirhisa .text-nowrapeka s ya wena <a>ku papalata mahanyelo lawa.
  • Ti popovers tifanele ku fihliwa loko ti elements ta tona leti fambelanaka tinga se susiwa eka DOM.
  • Popovers yinga pfuriwa hiku khensa element endzeni ka shadow DOM.
Hi ku tiyimisela, xiphemu lexi xi tirhisa xibasisi xa nhundzu lexi akiweke endzeni, lexi hluvulaka swiaki swihi na swihi swa HTML leswi nga pfumeleriwangiki hi ku kongoma. Vona xiyenge xa ​​sanitizer eka matsalwa ya hina ya JavaScript ku kuma vuxokoxoko byo tala.
Vuyelo bya animation bya xiphemu lexi byi titshege hi prefers-reduced-motionxivutiso xa midiya. Vona xiyenge xa ​​ku famba loku hungutiweke xa matsalwa ya hina ya ku fikelela .

Tshama u ri karhi u hlaya ku vona ndlela leyi ti- popover ti tirhaka ha yona hi swikombiso swin’wana.

Swikombiso

Endla leswaku ti-popovers ti tirha

Tani hilaha swinga boxiwaka hakona laha henhla, ufanele kusungula ti popovers loko tinga se tirhisiwa. Ndlela yin’wana yo sungula ti-popover hinkwato eka tluka ku nga va ku ti hlawula hi data-bs-togglexihlawulekisi xa tona, ku fana na sweswo:

const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]')
const popoverList = [...popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl))

Demo leyi hanyaka

Hi tirhisa JavaScript leyi fanaka na xiphemu lexi nga laha henhla ku hundzuluxela popover leyi landzelaka leyi hanyaka. Swihloko swi vekiwa hi ku tirhisa data-bs-titlenaswona nhundzu ya miri yi vekiwa hi ku tirhisa data-bs-content.

Titwele u ntshunxekile ku tirhisa yin’wana ya tona titlekumbe data-bs-titleeka HTML ya wena. Loko titleyi tirhisiwa, Popper yi ta yi siva hi yoxe hi data-bs-titleloko elemente yi hundzuluxeriwa.
html
<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>

Tindlela ta mune

Ku ni swilo swa mune leswi u nga swi hlawulaka: ehenhla, exineneni, ehansi ni le ximatsi. Swiletelo swi kombisiwa hi xivoni loko u tirhisa Bootstrap eka RTL. Seta data-bs-placementku cinca ndlela.

html
<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>

Ntolovelocontainer

Loko u ri na switayele swin’wana eka elemente ya mutswari leswi kavanyetaka popover, u ta lava ku boxa ntolovelo containerleswaku HTML ya popover yi humelela endzeni ka elemente yoleyo ematshan’wini ya sweswo. Leswi swi tolovelekile eka matafula lama hlamulaka, mintlawa ya swingheniso ni swin’wana swo fana na swona.

const popover = new bootstrap.Popover('.example-popover', {
  container: 'body'
})

Xiyimo xin’wana laha u nga ta lava ku veka mukhuva lowu nga erivaleni containeri ti-popovers endzeni ka mbulavurisano wa modal , ku tiyisisa leswaku popover hi yoxe yi engeteriwe eka modal. Leswi i swa nkoka swinene eka ti-popover leti nga na swiaki swo tirhisana – mimbulavurisano ya modal yi ta khoma ku kongomisa, kutani handle ka loko popover yi ri xiphemu xa n’wana xa modal, vatirhisi a va nge swi koti ku kongomisa kumbe ku tirhisa swiaki leswi swa vuhlanganisi.

const popover = new bootstrap.Popover('.example-popover', {
  container: '.modal-body'
})

Ti-popovers ta ntolovelo

Ku engeteriwe eka v5.2.0

U nga ha cinca ku languteka ka ti-popover hi ku tirhisa swilo leswi cinca-cincaka swa CSS . Hi veka tlilasi ya ntolovelo na data-bs-custom-class="custom-popover"ku scope xivumbeko xa hina xa ntolovelo ivi hi yi tirhisa ku tlula swin’wana swa swilo leswi cinca-cincaka swa CSS swa laha kaya.

.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;
}
html
<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 eka ku click loku landzelaka

Tirhisa focusxihlohloteri ku hlongola ti-popover eka ku tsindziyela loku landzelaka ka mutirhisi ka elemente yo hambana ku tlula elemente yo cinca-cinca.

Ku laveka ku fungha ko karhi eka ku hlongoriwa-eka-ku-click loku landzelaka

Ku kuma mahanyelo lamanene ya cross-browser na cross-platform, u fanele ku tirhisa <a>thegi, ku nga ri <button>thegi, naswona u fanele ku tlhela u katsa tabindexxihlawulekisi.

html
<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'
})

Swiaki leswi lamaleke

Swiaki leswi nga na disabledxihlawulekisi a swi tirhisani, leswi vulaka leswaku vatirhisi a va nge swi koti ku hover kumbe ku swi tsindziyela ku pfuxa popover (kumbe tooltip). Tanihi ndlela yo tshungula, u ta lava ku pfuxa popover ku suka eka xifunengeto <div>kumbe <span>, hi ndlela leyinene yi endliwe leswaku yi kongomisiwa eka khibhodi hi ku tirhisa tabindex="0".

Eka swihlohloteri swa popover leswi lamaleke, u nga ha tlhela u tsakela data-bs-trigger="hover focus"leswaku popover yi humelela tanihi vuyelo bya xihatla bya xivono eka vatirhisi va wena tanihileswi va nga ha langutelaka ku tikhoma eka elemente leyi lamaleke.

html
<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

Swilo leswi cinca-cincaka

Ku engeteriwe eka v5.2.0

Tanihi xiphemu xa ndlela ya Bootstrap leyi cinca-cincaka ya swilo leswi cinca-cincaka swa CSS, ti-popover sweswi ti tirhisa swilo leswi cinca-cincaka swa CSS swa laha kaya on .popoverfor enhanced real-time customization. Mimpimo ya swilo leswi cinca-cincaka swa CSS yi vekiwile hi ku tirhisa Sass, kutani ku cinca ka Sass ka ha seketeriwa, na kona.

  --#{$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 swilo leswi cinca-cincaka

$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;

Matirhiselo

Endla leswaku ti-popovers ti tirha hi ku tirhisa JavaScript:

const exampleEl = document.getElementById('example')
const popover = new bootstrap.Popover(exampleEl, options)

Ku endla leswaku ti-popover ti tirha eka vatirhisi va khibhodi ni thekinoloji yo pfuneta

Ku pfumelela vatirhisi va khibhodi ku tirhisa ti-popover ta wena, u fanele ku ti engetela ntsena eka swiaki swa HTML leswi hi ntolovelo swi kongomisiweke eka khibhodi na ku tirhisana (ku fana na swihlanganisi kumbe vulawuri bya fomo). Hambileswi swiaki swa HTML swa ku tihlawulela (swo tanihi <span>s) swi nga endliwaka swi kongomisiwa hi ku engetela tabindex="0"xihlawulekisi, leswi swi ta engetela ku yima ka tithebhu loku nga ha hlundzukisaka ni ku pfilunganya eka swiaki leswi nga riki swa vuhlanganisi eka vatirhisi va khibhodi, naswona thekinoloji yo tala leyi pfunaka sweswi a yi tivisi swilo swa popover eka xiyimo lexi . Ku engetela kwalaho, u nga titshegi ntsena hi hovertanihi xihlohloteri xa ti-popover ta wena, tanihi leswi leswi swi nga ta endla leswaku ti nga koteki ku ti pfuxa eka vatirhisi va khibhodi.

Hambileswi u nga nghenisaka HTML leyi fuweke, leyi hlelekeke eka ti-popovers hi htmlnhlawulo, hi ringanyeta swinene leswaku u papalata ku engetela nhlayo leyi tlulaka mpimo ya swilo leswi nga endzeni. Ndlela leyi ti popovers ti tirhaka ha yona sweswi hileswaku, loko ti kombisiwile, leswi nga endzeni ka swona swi boheleriwe eka trigger element leyi nga na aria-describedbyattribute. Hikwalaho ka sweswo, hinkwaswo leswi nga endzeni ka popover swi ta tivisiwa eka vatirhisi va thekinoloji leyi pfunaka tanihi xirhendzevutana xin’we xo leha, lexi nga kavanyetiwiki.

Ku engetela kwalaho, hambi leswi swi kotekaka ku tlhela u katsa vulawuri byo tirhisana (ku fana na swiaki swa xivumbeko kumbe swihlanganisi) eka popover ya wena (hi ku engetela swiaki leswi eka allowListya swihlawulekisi leswi pfumeleriweke na tithegi), tiva leswaku sweswi popover a yi lawuli ku landzelelana ka ku kongomisa ka khibhodi. Loko mutirhisi wa khibhodi a pfula popover, ku kongomisa ku tshama eka elemente leyi pfuxaka, naswona tanihi leswi popover hi ntolovelo yi nga hatliki ku landzelela trigger eka xivumbeko xa tsalwa, a ku na xitiyisekiso xa leswaku ku ya emahlweni/ku tshikilelaTAByi ta yisa mutirhisi wa khibhodi eka popover hi yoxe. Hi ku komisa, ku engetela ntsena vulawuri byo tirhisana eka popover swi nga ha endla leswaku vulawuri lebyi byi nga fikeleleki/ byi nga tirhisiwi eka vatirhisi va khibhodi na vatirhisi va thekinoloji yo pfuneta, kumbe hi mpimo lowutsongo swi endla leswaku ku va na oda ya ku kongomisa hi ku angarhela leyi nga twisisekiki. Eka swiyimo leswi, anakanya hi ku tirhisa mbulavurisano wa modal ematshan’wini ya sweswo.

Swihlawulekisi

Tanihi leswi swihlawulekisi swi nga hundziseriwaka hi ku tirhisa swihlawulekisi swa data kumbe JavaScript, u ​​nga engetela vito ra xihlawulekisi eka data-bs-, tanihi le ka data-bs-animation="{value}". Tiyisisa leswaku u cinca muxaka wa xiyimo xa vito ra xihlawulekisi ku suka eka “ camelCase ” ku ya eka “ kebab-case ” loko u hundzisa swihlawulekisi hi ku tirhisa swihlawulekisi swa data. Hi xikombiso, tirhisa data-bs-custom-class="beautifier"ematshan’weni ya data-bs-customClass="beautifier".

Ku sukela eka Bootstrap 5.2.0, swiphemu hinkwaswo swi seketela xihlawulekisi xa datha leyi hlayisiweke ya xikambelodata-bs-config lexi nga vekaka vukorhokeri byo olova bya xiphemu tanihi ntambhu ya JSON. Loko elemente yi ri data-bs-config='{"delay":0, "title":123}'na na data-bs-title="456"swihlawulekisi, titlentikelo wo hetelela wu ta va 456naswona swihlawulekisi swa datha leswi hambaneke swi ta tlula mimpimo leyi nyikiweke eka data-bs-config. Ku engetela kwalaho, swihlawulekisi swa datha leswi nga kona swi kota ku veka mimpimo ya JSON ku fana na data-bs-delay='{"show":0,"hide":150}'.

Xiya leswaku hikwalaho ka swivangelo swa vuhlayiseki sanitize, sanitizeFn, na allowListswihlawulekisi a swi nge nyikiwi hi ku tirhisa swihlawulekisi swa data.
Vito Muxaka Ku tlula Nhlamuselo
allowList nchumu Nhlayo ya xiviri Nchumu lowu nga na swihlawulekisi leswi pfumeleriweke na tithegi.
animation xitsonga xitsonga true Tirhisa ku cinca ka CSS fade eka popover.
boundary ntambhu, xiaki 'clippingParents' Ndzilakano wa xipimelo xa ku khuluka ka popover (wu tirha ntsena eka mucinci wa Popper wa preventOverflow). Hi ku tiyimisela, yi 'clippingParents'na naswona yi nga amukela xikombo xa HTMLElement (hi ku tirhisa JavaScript ntsena). Ku kuma vuxokoxoko byo tala languta eka Popper's detectOverflow docs .
container ntambhu, xiaki, mavunwa false Ku engetela popover eka elemente yo karhi. Xikombiso: container: 'body'. Nhlawulo lowu wu pfuna ngopfu hikuva wu ku pfumelela ku veka popover eka ku khuluka ka tsalwa ekusuhi na elemente yo hlohlotela - leswi nga ta sivela popover ku papamala ekule na elemente yo hlohlotela hi nkarhi wa ku cinca sayizi ya fasitere.
content ntambhu, xiaki, ntirho '' Ntsengo wa nhundzu ya xiviri loko data-bs-contentxihlawulekisi xi nga ri kona. Loko ntirho wu nyikiwile, wu ta vitaniwa hi thissete ya wona ya xikombo eka elemente leyi popover yi khomanisiweke na yona.
customClass ntambhu, ntirho '' Engetela titlilasi eka popover loko yi kombisiwa. Xiya leswaku titlilasi leti ti ta engeteriwa ku engetela eka titlilasi tihi na tihi leti boxiweke eka xifaniso. Ku engetela titlilasi to tala, ti hambanise hi swivandla: 'class-1 class-2'. U nga ha tlhela u hundzisela ntirho lowu faneleke ku vuyisa ntambhu yin’we leyi nga na mavito ya titlilasi yo engetela.
delay nomboro, nchumu 0 Ku hlwela ku kombisa na ku tumbeta popover (ms)—a swi tirhi eka muxaka wa manual trigger. Loko nomboro yi nyikiwile, ku hlwela ku tirhisiwa eka havumbirhi bya ku fihla/kombisa. Xivumbeko xa nchumu i: delay: { "show": 500, "hide": 100 }.
fallbackPlacements ntambhu, xirhendzevutani ['top', 'right', 'bottom', 'left'] Hlamusela swivandla swa fallback hi ku nyika nxaxamelo wa swivandla eka array (hi ku landzelelana ka ku tsakela). Ku kuma vuxokoxoko byo tala languta eka Popper's behavior docs .
html xitsonga xitsonga false Pfumelela HTML eka popover. Loko ku ri ntiyiso, tithegi ta HTML eka popover's titleti ta hundzuluxeriwa eka popover. Loko ku ri mavunwa, innerTextnhundzu yi ta tirhisiwa ku nghenisa nhundzu eka DOM. Tirhisa tsalwa loko u vilerisiwa hi nhlaselo wa XSS.
offset nomboro, ntambhu, ntirho [0, 0] Offset ya popover loko yi pimanisiwa na target ya yona. U nga hundzisa ntambhu eka swihlawulekisi swa datha hi mimpimo leyi hambanisiweke hi khoma ku fana na: data-bs-offset="10,20". Loko ntirho wu tirhisiwa ku kumisisa offset, wu vitaniwa hi nchumu lowu nga na popper placement, reference, na popper rects tani hi argument ya wona yo sungula. Node ya DOM ya elemente leyi hlohlotelaka yi hundziseriwa tanihi argument ya vumbirhi. Ntirho wu fanele ku vuyisa array leyi nga na tinomboro timbirhi: skidding , distance . Ku kuma vuxokoxoko byo tala languta eka Popper's offset docs .
placement ntambhu, ntirho 'top' Ndlela yo veka popover: auto, ehenhla, ehansi, eximatsini, exineneni. Loko autoswi boxiwile, yi ta dynamically yi tlhela yi kongomisa popover. Loko ntirho wu tirhisiwa ku kumisisa ku vekiwa, wu vitaniwa hi popover DOM node tanihi argument ya wona yo sungula na triggering element DOM node tanihi ya vumbirhi. Mongo thiswu vekiwile eka xikombiso xa popover.
popperConfig null, nchumu, ntirho null Ku cinca xivumbeko xa Popper xa xiviri xa Bootstrap, vona xivumbeko xa Popper . Loko ntirho wu tirhisiwa ku tumbuluxa xivumbeko xa Popper, wu vitaniwa hi nchumu lowu nga na xivumbeko xa Popper xa xiviri xa Bootstrap. Swi ku pfuna ku tirhisa ni ku hlanganisa leswi nga riki swa xiviri ni xivumbeko xa wena. Ntirho wu fanele ku vuyisa nchumu wa vuhlanganisi bya Popper.
sanitize xitsonga xitsonga true Endla leswaku ku tirhisiwa kumbe ku tshikisa ku basisiwa. If activated 'template', 'content'na 'title'swihlawulekisi swi ta sanitized.
sanitizeFn null, ntirho null Laha unga phakela ntirho wa wena wa sanitize. Leswi swinga pfuna loko u tsakela ku tirhisa layiburari leyi tinyiketeleke ku endla ku basisiwa.
selector ntambhu, mavunwa false Loko ku nyikiwile xihlawulekisi, swilo swa popover swi ta nyikiwa swikongomelo leswi boxiweke. Hi ku tirhisa, leswi swi tirhisiwa ku tlhela swi tirhisa ti-popover eka swiaki swa DOM leswi engeteriweke hi ndlela leyi cinca-cincaka ( jQuery.onnseketelo). Vona nkandziyiso lowu ni xikombiso lexi dyondzisaka .
template ntambu '<div class="popover" role="popover"><div class="popover-arrow"></div><div class="popover-inner"></div></div>' Base HTML ku tirhisa loko u endla popover. Popover's titleyi ta cheriwa eka .popover-inner. .popover-arrowyi ta hundzuka nseve wa popover. Xiphemu xa le handle xa xifunengeto xi fanele ku va na .popovertlilasi na role="popover".
title ntambhu, xiaki, ntirho '' Nhlayo ya xihloko xa xiviri loko titlexihlawulekisi xi nga ri kona. Loko ntirho wu nyikiwile, wu ta vitaniwa hi thissete ya wona ya xikombo eka elemente leyi popover yi khomanisiweke na yona.
trigger ntambu 'hover focus' Ndlela leyi popover yi sungulaka ha yona: click, hover, focus, manual. U nga ha hundza swihlohloteri swo tala; va hambanise hi xivandla. 'manual'yi kombisa leswaku popover yi ta sunguriwa hi nongonoko hi ku tirhisa .popover('show'), .popover('hide')na .popover('toggle')tindlela; ntikelo lowu a wu nge hlanganisiwi na xihlohloteri xin’wana. 'hover'hi yoxe swi ta endla leswaku ku va na ti-popovers leti nga ta ka ti nga pfuriwi hi ku tirhisa khibhodi, naswona ti fanele ku tirhisiwa ntsena loko tindlela tin’wana to hundzisela rungula leri fanaka eka vatirhisi va khibhodi ti ri kona.

Swihlawulekisi swa data swa ti-popover ta munhu hi xiyexe

Swihlawulekisi swa ti popovers ha yin’we yin’we tinga boxiwile hindlela yin’wana hiku tirhisa swihlawulekisi swa data, tani hileswi swinga hlamuseriwa laha henhla.

Ku tirhisa ntirho napopperConfig

const popover = new bootstrap.Popover(element, {
  popperConfig(defaultBsPopperConfig) {
    // const newPopperConfig = {...}
    // use defaultBsPopperConfig if needed...
    // return newPopperConfig
  }
})

Maendlelo

Maendlelo ya asynchronous na ku cinca

Maendlelo hinkwawo ya API i ya asynchronous naswona ya sungula ku cinca . Va tlhelela eka mufoyini hi ku hatlisa loko ku cinca ku sungurile kambe ku nga si hela . Ku engetela kwalaho, ku vitaniwa ka ndlela eka xiphemu lexi cincaka ku ta honisiwa .

Vona matsalwa ya hina ya JavaScript ku kuma vuxokoxoko byo tala .

Ndlela Nhlamuselo
disable Ku susa vuswikoti bya ku kombisiwa ka popover ya elemente. Popover yi ta kota ku kombisiwa ntsena loko yi tlhela yi tirhisiwa.
dispose Ku tumbeta no herisa popover ya elemente (Ku susa data leyi hlayisiweke eka elemente ya DOM). Popovers leyi tirhisaka delegation (leswi endliwaka hi ku tirhisa selectoroption ) a yi nge herisiwi hi yoxe eka ti descendant trigger elements.
enable Swi nyika popover ya elemente vuswikoti byo kombisiwa. Popovers yi tirhisiwa hi ku tiyimisela.
getInstance Ndlela ya static leyi ku pfumelelaka ku kuma xikombiso xa popover lexi fambelanaka na elemente ya DOM.
getOrCreateInstance Ndlela ya static leyi ku pfumelelaka ku kuma xikombiso xa popover lexi fambelanaka na elemente ya DOM, kumbe ku tumbuluxa leyintshwa loko ko tshuka ku nga sunguriwanga.
hide Ku tumbeta popover ya elemente. Ku tlhelela eka mufoyini loko popover yi nga si fihliwa hakunene (i.e. hidden.bs.popoverxiendlakalo xi nga si humelela). Leswi swi tekiwa tanihi ku hlohlotela “manual” ka popover.
setContent Yi nyika ndlela yo cinca leswi nga endzeni ka popover endzhaku ka ku sunguriwa ka yona.
show Ku paluxa popover ya elemente. Ku tlhelela eka mufoyini loko popover yi nga si kombisiwa hakunene (i.e. shown.bs.popoverxiendlakalo xi nga si humelela). Leswi swi tekiwa tanihi ku hlohlotela “manual” ka popover. Ti-popover leti nhloko-mhaka ya tona ni leswi nga endzeni ka tona swi nga zero-length a swi si tshama swi kombisiwa.
toggle Ku cinca-cinca popover ya elemente. Ku tlhelela eka mufoyini loko popover yi nga si kombisiwa hakunene kumbe ku tumbetiwa (i.e. emahlweni ka ku humelela shown.bs.popoverkumbe hidden.bs.popoverxiendlakalo). Leswi swi tekiwa tanihi ku hlohlotela “manual” ka popover.
toggleEnabled Toggles vuswikoti bya leswaku popover ya element yi kombisiwa kumbe ku fihliwa.
update Ku pfuxeta xiyimo xa popover ya elemente.
// 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'
})
Ndlela setContentyi amukela objectargument, laha property-key yin’wana na yin’wana yi nga stringxihlawulekisi lexi tirhaka endzeni ka popover template, naswona property-value yin’wana na yin’wana leyi fambelanaka yi nga va string| element| function| null

Swiendlakalo

Nkhuvo Nhlamuselo
hide.bs.popover Xiendlakalo lexi xi duvuriwa hi ku hatlisa loko ndlela ya hidexikombiso yi vitaniwile.
hidden.bs.popover Xiendlakalo lexi xi duvuriwa loko popover yi hetile ku tumbetiwa eka mutirhisi (yi ta rindza ku cinca ka CSS ku hela).
inserted.bs.popover Xiendlakalo lexi xi hlongoriwa endzhaku ka show.bs.popoverxiendlakalo loko xifaniso xa popover xi engeteriwile eka DOM.
show.bs.popover Xiendlakalo lexi xi pfurha hi ku hatlisa loko ku showvitaniwa ndlela ya xikombiso.
shown.bs.popover Xiendlakalo lexi xi hlongoriwa loko popover yi endliwile yi vonaka eka mutirhisi (yi ta rindza ku cinca ka CSS ku hela).
const myPopoverTrigger = document.getElementById('myPopover')
myPopoverTrigger.addEventListener('hidden.bs.popover', () => {
  // do something...
})