Popovers dɛn
Dokumɛnt ɛn ɛgzampul fɔ ad Bootstrap popovers, lɛk di wan dɛn we de na iOS, to ɛni ɛlimɛnt na yu sayt.
Tin dɛn fɔ no we yu de yuz di popover plɔgin:
- Popovers dipen pan di 3rd pati laybri Popper.js fɔ pozishɔn. Yu fɔ inklud popper.min.js bifo bootstrap.js ɔ yuz
bootstrap.bundle.min.js
/bootstrap.bundle.js
we gɛt Popper.js fɔ mek popovers wok! - Popovers nid di tultip plɔgin as dipɛnsin.
- If yu de bil wi JavaSkript frɔm sɔs, i nid fɔ
util.js
. - Popovers na opt-in fɔ pefɔmɛns rizin, so yu fɔ initialize dɛn yusɛf .
- Ziro-lɛngth
title
ɛncontent
valyu dɛn nɔ go ɛva sho wan popover. - Spɛsify
container: 'body'
fɔ avɔyd fɔ rɛnd prɔblɛm dɛn na mɔ kɔmpleks kɔmpɔnɛnt dɛn (lɛk wi input grup dɛn, bɔtin grup dɛn, ɛn ɔda wan dɛn). - Trigεr popovers pan hidden elements nɔ go wok.
- Popovers fɔ
.disabled
ɔdisabled
ɛlimɛnt dɛn fɔ trig pan wan wrap ɛlimɛnt. - We dɛn trig am frɔm anka dɛn we de rap akɔdin to bɔku layn dɛn, di popover dɛn go de sɛnt bitwin di ankɔ dɛn ɔl di wit. Yuz
white-space: nowrap;
pan yu<a>
s fɔ avɔyd dis bihayvya. - Popovers fɔ ayd bifo dɛn dɔn pul dɛn kɔrɛspɔndɛns ɛlimɛnt dɛn na di DOM.
Kɔntinyu fɔ rid fɔ si aw popovers de wok wit sɔm ɛgzampul dɛn.
Wan we fɔ initialize ɔl di popovers na wan pej go bi fɔ pik dɛn bay dɛn data-toggle
atribyut:
We yu gɛt sɔm stayl dɛn pan wan mama ɛn papa ɛlimɛnt we de ambɔg wan popover, yu go want fɔ spɛsifa wan kɔstɔm container
so dat di popover in HTML go apia insay da ɛlimɛnt de insted.
<button type="button" class="btn btn-lg btn-danger" data-toggle="popover" title="Popover title" data-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button>
Fo opshɔn dɛn de: ɔp, rayt, dɔŋ, ɛn lɛft alaynɛd.
Yuz di focus
triga fɔ dismis popovers pan di yuza in nɛks klik fɔ wan difrɛn ɛlimɛnt pas di tɔgl ɛlimɛnt.
Speshal mak we nid fɔ dismis-ɔn-nɛks-klik
Fɔ mek yu krɔs-brawza ɛn krɔs-pletfɔm biev fayn, yu fɔ yuz di <a>
tɛg, nɔto di <button>
tɛg, ɛn yu fɔ put wan tabindex
atribyut bak.
<a tabindex="0" class="btn btn-lg btn-danger" role="button" data-toggle="popover" data-trigger="focus" title="Dismissible popover" data-content="And here's some amazing content. It's very engaging. Right?">Dismissible popover</a>
Elemɛnt dɛn wit di disabled
atribyut nɔ de intaraktiv, we min se yuzman dɛn nɔ kin ebul fɔ hover ɔ klik dɛn fɔ trig wan popover (ɔ tultip). As wokarawnd, yu go want fɔ trig di popover frɔm wan wrap <div>
ɔ <span>
ɛn ɔvalayz di pointer-events
pan di disabled element.
Fɔ disabled popover triggers, yu kin lɛk bak data-trigger="hover"
so dat di popover go apia as kwik vijual fidbak to yu yuza dɛn as dɛn nɔ go ɛkspɛkt fɔ klik pan wan disabled element.
<span class="d-inline-block" data-toggle="popover" data-content="Disabled popover">
<button class="btn btn-primary" style="pointer-events: none;" type="button" disabled>Disabled button</button>
</span>
Enable popovers bay JavaSkript:
Yu kin pas opshɔn dɛn bay we yu yuz data atribyut ɔ JavaSkript. Fɔ data atribyut dɛn, ad di opshɔn nem to data-
, lɛk insay data-animation=""
.
Nem | Kayn | Balans | Tɔk bɔt |
---|---|---|---|
animashɔn fɔ di pikchɔ dɛn | boolean we dɛn kɔl | tru | Aplay wan CSS fade transishɔn to di popover |
kɔntena we dɛn kin put insay | string fɔ di wan dɛn we de | elemɛnt | lay | lay | Apɛnd di popover to wan patikyula ɛlimɛnt. Fɔ ɛgzampul: |
satisfay | string fɔ di wan dɛn we de | elemɛnt | wok | '' . | Difɔlt kɔntinyu valyu if If dɛn gi wan fɛnshɔn, dɛn go kɔl am wit in |
westɛm | nɔmba | tin | 0. Di wan dɛn we de | Dilay fɔ sho ɛn ayd di popover (ms) - nɔ de aplay to manual trigger type If dɛn gi wan nɔmba, dɛn kin delay fɔ ɔl tu di ayd/sho Objekt strɔkchɔ na: |
html | boolean we dɛn kɔl | lay | Put HTML insay di popover. If na lay, text dɛn go yuz jQuery in we fɔ put kɔntinyu insay di DOM. Yuz tɛks if yu de wɔri bɔt XSS atak dɛn. |
ples fɔ put am | string fɔ di wan dɛn we de | wok | 'rayt' | Aw fɔ posishun di popover - auto | top | dɔŋ ya | lɛft | rayt. We dɛn yuz wan fɛnshɔn fɔ no di plesmɛnt, dɛn kin kɔl am wit di popover DOM node as in fɔs argumɛnt ɛn di trigɛn ɛlimɛnt DOM node as in sɛkɔn. Di |
sɛlɛktɔ | string fɔ di wan dɛn we de | lay | lay | If dɛn gi wan sɛlɛktɔ, dɛn go deleget popover ɔbjɛkt dɛn to di target dɛn we dɛn dɔn spɛsifa. Insay prɔsis, dɛn kin yuz dis fɔ mek dinamik HTML kɔntinyu fɔ gɛt popovers we dɛn ad. Si dis ɛn wan ɛgzampul we gɛt bɔku tin dɛn fɔ no bɔt . |
tɛmplat fɔ di wan dɛn we de | rop | '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>' |
Base HTML fɔ yuz we yu de mek di popover. Di popover's Di popover's
Di ɔtamost wrap ɛlimɛnt fɔ gɛt di |
taytul | string fɔ di wan dɛn we de | elemɛnt | wok | '' . | Difɔlt taytul valyu if If dɛn gi wan fɛnshɔn, dɛn go kɔl am wit in |
stat | rop | 'klik'. | Aw popover de trig - klik | hover fɔ di wan dɛn we de wok | fɔs fɔs | buk. Yu kin pas bɔku trig dɛn; separet dɛn wit wan ples. `manual` nɔ kin kam togɛda wit ɛni ɔda trig. |
ɔfset | nɔmba | rop | 0. Di wan dɛn we de | Offset of di popover rilitiv to in target. Fɔ no mɔ, luk na Popper.js in ɔfset dɔkyumɛnt dɛn . |
fallbackPlesmɛnt fɔ put | string fɔ di wan dɛn we de | arenjmɛnt fɔ di wan dɛn we de | 'tɔn oba' | Alaw fɔ spɛsifa us pozishɔn Popa go yuz pan fɔl bak. Fɔ no mɔ, luk na Popper.js in bihayvya dɔkyumɛnt dɛn |
bɔda | string fɔ di wan dɛn we de | tin | 'skrolParent'. | Ovaflɔ kɔnstrakshɔn bɔda fɔ di popover. Aksept di valyu dɛn fɔ 'viewport' , 'window' , 'scrollParent' , ɔ wan HTMLElement rɛfrɛns (JavaSkript nɔmɔ). Fɔ no mɔ, luk na Popper.js in preventOverflow docs . |
Data atribyut fɔ wan wan popover dɛn
Opshɔn fɔ wan wan popover dɛn kin ɔda we fɔ spɛsifa tru di yus fɔ data atribyut dɛn, as dɛn ɛksplen am ɔp.
Asynchronous mεtכd dεm εn transishכn dεm
Ɔl di API mɛtɔd dɛn na asynchronous ɛn dɛn kin stat wan transishɔn . Dɛn kin go bak to di pɔsin we kɔl am jɔs lɛk aw dɛn bigin fɔ chenj bɔt bifo i dɔn . Apat frɔm dat, dɛn go ignore wan mɛtɔd kɔl pan wan transishɔn kɔmpɔnɛnt .
Initializes popovers fɔ wan ɛlimɛnt kɔllɛkshɔn.
Rivɛl wan ɛlimɛnt in popover. Ritɔn to di pɔsin we kɔl bifo di popover dɔn rili sho (dat na bifo di shown.bs.popover
ivin apin). Dɛn kin tek dis as “manual” we de trig di popover. Popovers we dɛn ɔl tu taytul ɛn kɔntinyu na zero-lɛngth nɔ de ɛva sho.
Ayd wan ɛlimɛnt in popover. Ritɔn to di pɔsin we kɔl bifo di popover dɔn rili ayd (dat na bifo di hidden.bs.popover
ivin apin). Dɛn kin tek dis as “manual” we de trig di popover.
Toggles wan element in popover. Ritɔn to di pɔsin we kɔl bifo di popover dɔn rili sho ɔ ayd (dat na bifo di shown.bs.popover
ɔ hidden.bs.popover
ivin apin). Dɛn kin tek dis as “manual” we de trig di popover.
Ayd ɛn pwɛl wan ɛlimɛnt in popover. Popovers we de yuz delegɛshɔn (we dɛn mek yuz di selector
opshɔn ) nɔ kin ebul fɔ pwɛl wan wan pan disɛndant trig ɛlimɛnt dɛn.
Gi wan element in popover di abiliti fɔ sho. Popovers dɛn dɔn ɛnabul bay difɔlt.
Rimov di abiliti fɔ wan ɛlimɛnt in popover fɔ sho. Di popover go onli ebul fɔ sho if dɛn ri-enable am.
Toggles di abiliti fɔ wan element in popover fɔ sho ɔ ayd.
Updates di posishun fɔ wan ɛlimɛnt in popover.
Di kayn tin we apin | Tɔk bɔt |
---|---|
sho.bs.popover fɔ di wan dɛn we de | Dis ivent de faya wantɛm wantɛm we dɛn kɔl di show instans mɛtɔd. |
sho.bs.popova | Dis ivent de faya we di popover dɔn mek visible to di yuza (go wet fɔ CSS transishɔn fɔ dɔn). |
ayd.bs.popover fɔ di wan dɛn we de | Dis ivent de faya wantɛm wantɛm we hide dɛn dɔn kɔl di instans mɛtɔd. |
ayd.bs.powa we de | Dis ivent de faya we di popover dɔn dɔn fɔ ayd frɔm di yuza (go wet fɔ CSS transishɔn dɛn fɔ dɔn). |
insay.bs.poova | Dis ivent de faya afta di show.bs.popover ivent we dɛn dɔn ad di popover tɛmplat to di DOM. |