Source

Tuñiy

Huk pisi clasekunawan chaymanta JavaScript pluginsniykuwan tukuy proyectoykipi contenidopa rikuyninta tikray.

Imayna llamkan

JavaScript urmachiy plugin llamk'achisqa kachkan rikuchiypaq chaymanta pakaypaq. Botonkuna utaq anclakuna gatillokuna hina llamk'achkanku chaymanta elementokuna específicos kaqman mapeasqa kanku mayqinkunatachus tikranki. Huk elementota urmachispaqa heightkunan chaniyuqmanta 0. Imayna CSS kawsachiykunata hap'in chayta qusqa, mana paddinghuk .collapseelemento kaqpi llamk'achiy atikunkichu. Aswanpas, claseta huk sapanchasqa p'istu elemento hina llamk'achiy.

Qatina

Uraypi kaq ñit'inakunata ñit'iy huk elementota rikuchinaykipaq chaymanta pakanaykipaq clase tikraykunawan:

  • .collapsecontenidota pakan
  • .collapsingtransiciones nisqapi churakun
  • .collapse.showcontenido nisqatam qawachin

Huk t'inkita llamk'achiyta atinki hrefatributowan, icha huk ñit'inata data-targetatributowan. Iskayninpipas, chay data-toggle="collapse"nisqa kamachisqa kachkan.

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

Achka metakuna

A <button>utaq <a>achka elementokunata rikuchiyta chaymanta pakayta atin huk JQuery akllaqwan paypa hrefutaq data-targetatributonpi referenciaspa. Achka <button>utaq <a>huk elementota rikuchiyta chaymanta pakayta atin sichus sapankanku paykunap hrefutaq data-targetatributowan referencianku

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

Ejemplo de acordeón

Tarjeta componente llamk'achispa , ñawpaqmanta urmachiy ruwayta mast'ariyta atikunki huk acordeón ruwanapaq.

Anim pariatur cliché reprehenderit, enim eiusmod alto vida acusamus terry richardson ad calamar. 3 lobo killa officia aute, mana cupidatat patineta dolor brunch. Mikhuy apaykachana quinoa nesciunt laborum eiusmod. Brunch 3 lobo killa tempor, sunt aliqua churan huk pisquta chayman calamar huk-origen café nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, artesanía cerveza llamk'ay wes anderson cred nesciunt sapiente ea proident. Anuncio vegano excepteur carnicero vice lomo. Polainas occaecat artesanía cerveza granja-a-mesa, crudo denim estético synth nesciunt ichapas mana uyarirqankichu paykunamanta accusamus labore sostenible VHS.
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.
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 class="accordion" id="accordionExample">
  <div class="card">
    <div class="card-header" id="headingOne">
      <h5 class="mb-0">
        <button class="btn btn-link" type="button" 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="#accordionExample">
      <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" type="button" 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="#accordionExample">
      <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" type="button" 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="#accordionExample">
      <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>

Accesibilidad nisqa

aria-expandedAswan allinta qhaway elemento de control nisqaman yapayta . Kay atributo explícitamente kunan estadota elemento colapsible controlman watasqa pantalla ñawiriqkunaman chaymanta rikch'aq yanapakuy tecnologiakunaman apachin. Sichus t'inkisqa elemento ñawpaqmanta wichq'asqa kachkan, kamachiy elementopi atributo chaniyuq kanan tiyan aria-expanded="false". Sichus t'inkisqa elementota kichasqa kananpaq churarqanki ñawpaqmanta showclase kaqwan, aria-expanded="true"kamachiypi churay chaymanta ranti. Plugin kikinmanta kay atributota kamachiypi tikranqa sichus utaq mana ñit'isqa elemento kichasqa utaq wichq'asqa (JavaScript kaqninta, utaq imaraykuchus llamk'achiq huk kamachiy elementota kikin collapsbile elementoman watasqa kaqtapas llamk'achirqan). Sichus kamachiq elementopa HTML elementon mana huk ñit'inachu (kayhina, huk <a>icha <div>), layarole="button"chay elementoman yapakunan tiyan.

Sichus kamachiy elementoyki huk sapalla ñit'iy atikuq elementota maskachkan – chaymanta data-targetatributo huk akllaqman rikuchichkan – atributota kamachiy elementoman idyapanayki tiyan , chaymanta chay de collapsible elemento kaqmanta. Kunan pantalla ñawiriqkuna chaymanta rikch'aq yanapakuy tecnologiakuna kay atributota llamk'achinku ruwaqkunaman yapa llalliq ñankuna qunankupaq chiqalla purinankupaq kikin elemento collapsible kaqman.aria-controlsid

Reparay Bootstrap kunan ruwaynin mana imaymana teclado tinkiykuna WAI-ARIA Autorización Ruwaykuna 1.1 acordeón patrón kaqpi willasqa llanthunchu - kaykunata qam kikiyki JavaScript ruwasqawan churanayki tiyan.

Uso

Urmachiy plugin huk pisi clasekunata llamk'achin llasa hoqariyta llamk'achinapaq:

  • .collapsechaypi kaqta pakaykun
  • .collapse.showchaypi kaqta rikuchin
  • .collapsingtikray qallariptin yapasqa, tukuptintaq hurqusqa

Kay clasekunataqa tarinki _transitions.scss.

Atributos de datos nisqawan

Yanapakuylla data-toggle="collapse"chaymanta huk data-targetelementoman kikillanmanta huk utaq achka elementokuna collapsiblekuna kamachiyta churanapaq. Atributo data-targethuk CSS akllanata chaskikun chayman urmachiyta churanapaq. Aswan allinta yapay chay claseta collapsechay elemento collapsible nisqaman. Sichus ñawpaqmanta kichasqa kananta munanki, yapasqa claseta yapay show.

Acordeón hina huñu kamachiyta huk p'istuy kitiman yapanaykipaq, willay laya yapay data-parent="#selector". Kayta ruwaypi qhawanaykipaq demo nisqapi qhaway.

JavaScript nisqawan

Makiwan atichiy kaykunawan:

$('.collapse').collapse()

Akllanakuna

Akllanakuna willay layakuna utaq JavaScript kaqnintakama pasayta atikun. Willayta layakunapaq, akllana sutita yapay data-, imaynachus data-parent="".

Suti Niraq Ñawpaqchasqa Willay
tayta mama akllaq | jTapukuy objeto | Elemento DOM nisqa pantasqa Sichus tayta mama qusqa, chaymanta llapa t'inkisqa elementokuna nisqa tayta mamap urapi wichq'asqa kanqa mayk'aq kay t'inkisqa imayay rikuchisqa. card(ñawpamanta pacha acordeón ruwayman rikch'akuq - kayqa clasemanta dependen ). Atributoqa churasqa kanan tiyan chay meta collapsible nisqapi.
toggle nisqa boolean nisqa chiqaq Invocacionpi colapsible elementota tikran

Métodos

Métodos y transiciones asíncronas

Llapan API ruwanakuna mana sink'uyuq kanku chaymanta huk tikrayta qallarinku . Paykunaqa kutinku waqyaqman chaylla transición qallarisqa ichaqa manaraq tukukuchkaptin . Chaymantapas, huk tikray componente kaqpi huk método waqyay mana qhawasqachu kanqa .

Aswan willakuypaq JavaScript qillqaykuta qhaway.

.collapse(options)

Contenidoykita huk elemento collapsible hina activan. Huk akllana akllanakunata chaskikun object.

$('#myCollapsible').collapse({
  toggle: false
})

.collapse('toggle')

Huk ñit'isqa elementota rikuchisqaman icha pakasqaman tikran. Llamaqman kutimun manaraq llalliq elemento chiqamanta rikuchisqa utaq pakasqa kachkaptin (icha manaraq shown.bs.collapseutaq hidden.bs.collapseruway ruwakuchkaptin).

.collapse('show')

Huk llalliq elementota rikuchin. Llamaqman kutimun manaraq t'inkisqa elemento chiqamanta rikuchisqa kachkaptin (icha manaraq shown.bs.collapseruway ruwakuchkaptin).

.collapse('hide')

Huk llalliq elementota pakan. Llamaqman kutimun manaraq t'inkisqa elemento chiqamanta pakasqa kachkaptin (icha manaraq hidden.bs.collapseruway ruwakuchkaptin).

.collapse('dispose')

Huk elementopa urmayninta chinkachin.

Eventos nisqakuna

Bootstrap kaqpa urmachiy clase huk pisi ruwaykunata riqsichin urmachiy ruwanaman enganche kaqpaq.

Tipo de Evento Willay
rikuchiy.bs.collapse Kay ruwayqa chaylla rawrarin mayk'aq showinstancia método waqyasqa.
rikuchisqa.bs.collapse Kay ruwayqa llamk'achisqa huk urmachiy elemento ruwaqman rikukuq ruwasqa kaqtin (CSS tikraykunata tukunanta suyanqa).
pakay.bs.ch'usaqyachiy Kay ruwayqa chaylla llamk'achisqa kachkan mayk'aqchus hidemétodo waqyasqa kachkan.
pakasqa.bs.collapse nisqa Kay ruwayqa llamk'achiqmanta huk urmachiy elemento pakasqa kaptin llamk'achisqa (CSS tikraykunata tukunanta suyanqa).
$('#myCollapsible').on('hidden.bs.collapse', function () {
  // do something…
})