Goqa
Guqula ukubonakala kokuqukethwe kuyo yonke iphrojekthi yakho ngamakilasi ambalwa nama-plugin ethu e-JavaScript.
Chofoza izinkinobho ezingezansi ukuze ubonise futhi ufihle enye into ngezinguquko zekilasi:
.collapse
ifihla okuqukethwe.collapsing
isetshenziswa ngesikhathi soshintsho.collapse.show
ikhombisa okuqukethwe
Ungasebenzisa isixhumanisi href
esinesibaluli, noma inkinobho data-target
enesibaluli. Kuzo zombili izimo, data-toggle="collapse"
kuyadingeka.
<p>
<a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
Link with href
</a>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
Button with data-target
</button>
</p>
<div class="collapse" id="collapseExample">
<div class="card card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</div>
</div>
I-A <button>
noma <a>
ingabonisa futhi ifihle izici eziningi ngokuzibhekisela ngesikhethi se-JQuery kuso href
noma data-target
kusibaluli. Okuningi <button>
noma <a>
kungabonisa futhi kufihle into uma ngamunye ebhekisela kuyo href
noma data-target
ngesibaluli sakhe
<p>
<a class="btn btn-primary" data-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Toggle first element</a>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#multiCollapseExample2" aria-expanded="false" aria-controls="multiCollapseExample2">Toggle second element</button>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1 multiCollapseExample2">Toggle both elements</button>
</p>
<div class="row">
<div class="col">
<div class="collapse multi-collapse" id="multiCollapseExample1">
<div class="card card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</div>
</div>
</div>
<div class="col">
<div class="collapse multi-collapse" id="multiCollapseExample2">
<div class="card card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</div>
</div>
</div>
</div>
Usebenzisa ingxenye yekhadi , unganweba ukuziphatha kokugoqa okuzenzakalelayo ukuze udale i-accordion.
<div id="accordion">
<div class="card">
<div class="card-header" id="headingOne">
<h5 class="mb-0">
<button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Collapsible Group Item #1
</button>
</h5>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingTwo">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
Collapsible Group Item #2
</button>
</h5>
</div>
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingThree">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
Collapsible Group Item #3
</button>
</h5>
</div>
<div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
</div>
Qiniseka ukuthi ungeza aria-expanded
kusici sokulawula. Lesi sibaluli siveza ngokusobala isimo samanje sento egoqekayo eboshelwe ekulawuleni izifundi zesikrini nobuchwepheshe obusizayo obufanayo. Uma i-elementi egoqekayo ivalwa ngokuzenzakalelayo, isibaluli sesici sokulawula kufanele sibe nenani elithi aria-expanded="false"
. Uma usethe i-elementi egoqekayo ukuthi ivuleke ngokuzenzakalela usebenzisa show
iklasi, setha aria-expanded="true"
kusilawuli esikhundleni salokho. I-plugin izoguqula ngokuzenzakalelayo lesi sibaluli kusilawuli ngokusekelwe ekutheni i-elementi egoqekayo ivuliwe noma ivaliwe yini (nge-JavaScript, noma ngenxa yokuthi umsebenzisi ucuphe enye into yokulawula nayo eboshelwe kwinto efanayo ye-collapsbile). Uma i-elementi ye-HTML yento yokulawula ingeyona inkinobho (isb., i <a>
noma <div>
), isibalulirole="button"
kufanele kwengezwe ku-elementi.
Uma i-elementi yakho yokulawula iqondise kwinto eyodwa egoqekayo - okungukuthi data-target
isibaluli sikhomba id
kusikhethi - kufanele wengeze aria-controls
isici sokulawula, esiqukethe id
into egoqekayo. Izifundi zesikrini zesimanje kanye nobuchwepheshe bokusiza obufanayo busebenzisa lesi sici ukuze banikeze abasebenzisi izinqamuleli ezengeziwe ukuze bazulazule ngokuqondile ku-elementi egoqekayo ngokwayo.
Qaphela ukuthi ukusebenzisa kwamanje kwe-Bootstrap akubandakanyi ukusebenzisana okuhlukahlukene kwekhibhodi okuchazwe kuphethini ye-accordion ye-WAI-ARIA 1.1 - uzodinga ukuzifaka wena ngokwakho ne-JavaScript yangokwezifiso.
I-plugin yokugoqa isebenzisa amakilasi ambalwa ukuphatha ukuphakamisa okusindayo:
.collapse
ifihla okuqukethwe.collapse.show
ikhombisa okuqukethwe.collapsing
yengezwa lapho inguquko iqala, futhi ikhishwe lapho iqeda
Lawa makilasi angatholakala ku _transitions.scss
.
Vele ungeze data-toggle="collapse"
futhi u-a entweni data-target
ukuze unikeze ngokuzenzakalelayo ukulawula kwe-elementi eyodwa noma eziningi ezigoqekayo. Isibaluli data-target
samukela isikhethi se-CSS ongafaka kuso ukugoqa. Qiniseka ukuthi ungeza ikilasi collapse
ku-elementi egoqekayo. Uma ungathanda ukuthi ivuleke ngokuzenzakalelayo, engeza iklasi elengeziwe show
.
Ukuze ungeze ukuphathwa kweqembu okufana ne-accordion endaweni egoqekayo, engeza isibaluli sedatha data-parent="#selector"
. Bheka idemo ukuze ubone lokhu kusebenza.
Nika amandla ngokwenza nge:
Izinketho zingadluliswa ngezibaluli zedatha noma i-JavaScript. Ukuze uthole izibaluli zedatha, faka igama lenketho kokuthi data-
, njengaku data-parent=""
.
Igama | Uhlobo | Okuzenzakalelayo | Incazelo |
---|---|---|---|
umzali | isikhethi | into ye-jQuery | Isici se-DOM | amanga | Uma umzali enikeziwe, khona-ke zonke izici ezigoqekayo ngaphansi komzali othile zizovalwa lapho le nto egoqekayo iboniswa. (okufana nokuziphatha kwe-accordion yendabuko - lokhu kuncike card ekilasini). Isibaluli kufanele simiswe endaweni egoqekayo eqondiwe. |
guqula | boolean | iqiniso | Iguqula into egoqekayo ekunxuseni |
Izindlela ze-Asynchronous kanye noshintsho
Zonke izindlela ze-API azivumelanisi futhi ziqala inguquko . Abuyele kofonayo uma sekuqalwa uguquko kodwa lungakapheli . Ngaphezu kwalokho, ikholi yendlela engxenyeni yoshintsho izozitshwa .
Bona imibhalo yethu ye-JavaScript ukuze uthole ulwazi olwengeziwe.
Yenza okuqukethwe kwakho kusebenze njengento egoqekayo. Yamukela izinketho ozikhethela object
.
Iguqula into egoqekayo ukuze iboniswe noma ifihlwe. Ibuyela kofonayo ngaphambi kokuba into egoqekayo iboniswe noma ifihlwe (okungukuthi ngaphambi kokuba kwenzeke shown.bs.collapse
noma hidden.bs.collapse
isigameko).
Ibonisa into egoqekayo. Ibuyela kofonayo ngaphambi kokuba into egoqekayo iboniswe (okungukuthi ngaphambi kokuba shown.bs.collapse
kwenzeke umcimbi).
Ifihla into egoqekayo. Ibuyela kofonayo ngaphambi kokuba into egoqekayo ifihleke (okungukuthi ngaphambi kokuthi hidden.bs.collapse
kwenzeke umcimbi).
Icekela phansi ukuwa kwento.
Ikilasi lokugoqa le-Bootstrap lidalula imicimbi embalwa ukuze ixhumeke ekusebenzeni kokugoqa.
Uhlobo Lomcimbi | Incazelo |
---|---|
show.bs.goqa | Lo mcimbi uvutha ngokushesha lapho show indlela yesibonelo ibizwa. |
ikhonjisiwe.bs.goqa | Lo mcimbi uxoshwa lapho isici sokugoqa senziwe sabonakala kumsebenzisi (sizolinda ukuguqulwa kwe-CSS ukuthi kuqedwe). |
fihla.bs.goqa | Lo mcimbi uxoshwa ngokushesha lapho hide indlela isibiziwe. |
kufihlwe.bs.goqa | Lo mcimbi uxoshwa lapho isici sokugoqa sifihliwe kumsebenzisi (sizolinda ukuthi izinguquko ze-CSS ziqedele). |