Fa Bootstrap no afã horow no ba nkwa mu —seesei de jQuery plugins 13 a wɔahyɛ da ayɛ.
Wobetumi de plugins aka ho mmiako mmiako (ɛwom sɛ ebinom ahwehwɛ sɛ wɔde wɔn ho to so), anaasɛ ne nyinaa prɛko pɛ. Bootstrap.js ne bootstrap.min.js nyinaa kura plugins nyinaa wɔ fael biako mu.
Wubetumi de Bootstrap plugins nyinaa adi dwuma denam markup API no so ara kwa a worenkyerɛw JavaScript line biako mpo. Eyi yɛ Bootstrap API a edi kan no na ɛsɛ sɛ ɛyɛ nea edi kan a wususuw ho bere a wode plugin redi dwuma no.
Ɛno akyi no, wɔ tebea horow bi mu no, ebia ɛbɛyɛ papa sɛ wudum saa dwumadi yi. Enti, yɛsan nso ma tumi a yɛde besiw data attribute API no ano denam nsɛm a esisi nyinaa a wobeyi afi nipadua no din a wɔde `'data-api'` ahyɛ mu no so. Eyi te sɛ eyi:
- $ ( 'nipadua' ). off ( '.data-api' ) na ɛwɔ hɔ.
Sɛnea ɛbɛyɛ a, sɛ wopɛ sɛ wode w’ani si plugin pɔtee bi so a, fa plugin no din ka ho kɛkɛ sɛ dinbea ka data-api dinbea no ho te sɛ eyi:
- $ ( 'nipadua' ). off ( '.akɔbɔ.data-api' ) .
Yɛsan nso gye di sɛ ɛsɛ sɛ wutumi de Bootstrap plugins nyinaa di dwuma denam JavaScript API no so ara kwa. Ɔmanfoɔ API nyinaa yɛ akwan baako, a wɔde nkɔnsɔnkɔnsɔn gu so, na ɛsan de nneɛma a wɔaboaboa ano a wɔayɛ ho adwuma no ba.
- $ ( ".btn.asiane" ). bɔtɔn ( "toggle" ). addKlas ( "srade" ) .
Ɛsɛ sɛ akwan nyinaa gye optional options ade, ahama a ɛde n’ani si ɔkwan pɔtee bi so, anaasɛ biribiara (a ɛhyɛ plugin ase a ɛwɔ default suban):
- $ ( "#meModal" ). modal () // wɔde default ahorow ahyɛ ase
- $ ( "#meModal" ). modal ({ keyboard : atoro }) // ahyɛ aseɛ a keyboard biara nni mu
- $ ( "#meModal" ). modal ( 'show' ) // hyɛ ase na ɛfrɛ kyerɛ ntɛm ara
Plugin biara nso da ne raw constructor adi wɔ `Constructor` agyapade bi so: $.fn.popover.Constructor
. Sɛ wopɛ sɛ wonya plugin nhwɛso pɔtee bi a, gye no tẽẽ fi element bi mu: $('[rel=popover]').data('popover')
.
Ɛtɔ da bi a ɛho hia sɛ wode Bootstrap plugins di dwuma ne UI frameworks afoforo. Wɔ saa tebea horow yi mu no, edin-ahunmu nhyiam betumi aba bere ne bere mu. Sɛ eyi ba a, wubetumi afrɛ .noConflict
plugin a wopɛ sɛ wosan de bo no ba no.
- var bootstrapBɔtɔn = $ . fn . bɔtɔn no . noConflict () // san $.fn.button kɔ botae a wɔadi kan de ama no so
- $ . fn . bootstrapBtn = bootstrapButton // ma $().bootstrapBtn bootstrap dwumadie no
Bootstrap de nsɛm a esisi a wɔahyɛ da ayɛ ma plugin no nneyɛe soronko dodow no ara. Mpɛn pii no, eyinom ba wɔ infinitive ne past participle kwan so - faako a infinitive (ex. show
) no kanyan wɔ adeyɛ bi mfiase, na ne past participle kwan (ex. shown
) no kanyan bere a adeyɛ bi awie no.
Nsɛm a esisii a enni awiei nyinaa ma preventDefault dwumadie. Eyi ma wotumi gyina adeyɛ bi a wɔyɛ no ano ansa na afi ase.
- $ ( '#meModal' ). on ( 'kyerɛ' , dwumadie ( e ) { .
- sɛ (! data ) san ba e . preventDefault () // gyae modal a wɔde bɛkyerɛ
- }) na .
Sɛ wopɛ nsakrae nsunsuanso a ɛnyɛ den a, fa bootstrap-transition.js ka JS fael afoforo no ho pɛnkoro. Sɛ wode bootstrap.js a wɔaboaboa ano (anaasɛ wɔayɛ no ketewaa) no redi dwuma a , ɛho nhia sɛ wode eyi bɛka ho—ɛwɔ hɔ dedaw.
Nsakraeɛ plugin no ho nhwɛsoɔ kakra:
Modals no yɛ streamlined, nanso ɛyɛ mmerɛw, nkɔmmɔbɔ nsɛm a ɛkyerɛ a ɛwɔ dwumadie a ɛsua koraa a wɔhwehwɛ ne smart defaults.
Modal a wɔakyerɛ ase a ɛwɔ atiri, nipadua, ne nneyɛe ahorow a wɔahyehyɛ wɔ ase hɔ.
Nipadua pa biako...
- <div adesuakuw = "modal hide fade" >
- <div adesuakuw = "modal-atiri" >
- <button type = "button" class = "to" data-dismiss = "modal" aria-hidden = "nokware" > &mmere; </button> no ho
- <h3> Modal asɛmti </h3>
- </div> no
- <div adesuakuw = "modal-nipadua" >
- <p> Nipadua pa biako... </p>
- </div> no
- <div adesuakuw = "modal-nan ase" >
- <a href = "#" adesuakuw = "btn" > To mu </a>
- <a href = "#" class = "btn btn-primary" > Sie nsakraeɛ </a>
- </div> no
- </div> no
Toggle a modal via JavaScript denam button a ɛwɔ ase ha no a wobɛma so. Ɛbɛtwetwe akɔ fam na ɛbɛyera afi kratafa no atifi.
- <!-- Button a ɛbɛkanyan modal -->
- <a href = "#myModal" dwumadie = "bɔtn" adesuakuw = "btn" data-toggle = "modal" > Fi ase demo modal </a>
- <!-- Modal --> a ɛyɛ nwonwa
- <div id = "meModal" adesuakuw = "modal hide fade" tabindex = "-1" dwuma = "nkɔmmɔbɔ" aria-labelledby = "meModalLabel" aria-hidden = "nokware" >
- <div adesuakuw = "modal-atiri" >
- <button type = "button" class = "to" data-dismiss = "modal" aria-hidden = "nokware" > × </button>
- <h3 id = "myModalLabel" > Modal asɛmti </h3>
- </div> no
- <div adesuakuw = "modal-nipadua" >
- <p> Nipadua pa biako... </p>
- </div> no
- <div adesuakuw = "modal-nan ase" >
- <button class = "btn" data-dismiss = "modal" aria-hidden = "nokware" > Ka </button> mu
- <button class = "btn btn-primary" > Sie nsakraeɛ </button>
- </div> no
- </div> no
Fa modal bi yɛ adwuma a wonkyerɛw JavaScript. Fa data-toggle="modal"
si controller element bi so, te sɛ button, ne a data-target="#foo"
anaasɛ href="#foo"
sɛ wode besi modal pɔtee bi so sɛ wobɛdannan.
- <button type = "button" data-toggle = "modal" data-botae = "#myModal" > Fi ase modal </button>
Frɛ modal a ɛwɔ id myModal
a ɛwɔ JavaScript line biako:
- $ ( '#meModal' ). modal ( nneɛma a wobetumi apaw ) .
Wobetumi afa data attributes anaa JavaScript so de nneɛma a wobɛpaw no akɔ. Sɛ wopɛ data su ahorow a, fa option din no ka ho data-
, sɛnea ɛwɔ data-backdrop=""
.
Din | korɔ | mfiaseɛ | nkyerɛmu |
---|---|---|---|
akyi mfonini | boolean ho asɛm | nokorɛ | Nea ɛka ho ne modal-backdrop element bi. Sɛnea ɛbɛyɛ a, kyerɛ static ma akyigyina a ɛnto modal no mu wɔ klik so. |
keyboard so nsɛm | boolean ho asɛm | nokorɛ | Ɛto modal no mu bere a wɔabɔ escape key no |
da no adi | boolean ho asɛm | nokorɛ | Kyerɛ modal no bere a wɔahyɛ ase no. |
akurase tuu | kwan | ɛnyɛ ampa | Sɛ wɔde akyirikyiri url ma a, wɔde nsɛm no bɛfa jQuery
|
Ɛma wo nsɛm no yɛ adwuma sɛ modal. Gye akwan a wubetumi apaw bi tom object
.
- $ ( '#meModal' ). ɔkwan a wɔfa so yɛ ade ({
- keyboard : atoro
- }) na .
Nsaano toggles a modal.
- $ ( '#meModal' ). modal ( 'nsakrae' ) .
Nsaano bue modal bi.
- $ ( '#meModal' ). modal ( 'kyerɛ' ) .
Nsaano de sie modal bi.
- $ ( '#meModal' ). modal ( 'de sie' ) .
Bootstrap no modal adesuakuw no da nsɛm kakraa bi a esisii adi ma hooking kɔ modal dwumadi mu.
Dwumadie | Nkyerɛmu |
---|---|
da no adi | Saa adeyɛ yi tow ntɛm ara bere a show wɔfrɛ instance kwan no. |
a wɔakyerɛ | Wɔtow saa adeyɛ yi bere a wɔayɛ modal no ahu nea ɔde di dwuma no (bɛtwɛn ma css nsakrae ahorow no awie). |
tɛ | Wɔtow saa adeyɛ yi ntɛm ara bere a hide wɔafrɛ instance kwan no. |
asuma | Wɔtow saa adeyɛ yi bere a modal no awie sɛ wɔde asie afi ɔdefo no hɔ (bɛtwɛn ma css nsakrae ahorow no awie). |
- $ ( '#meModal' ). on ( 'ahintaw' , adwuma () { .
- // yɛ biribi...
- }) na .
Fa dropdown menus ka ɛkame ayɛ sɛ biribiara ho denam saa plugin a ɛnyɛ den yi so, a navbar, tabs, ne pills ka ho.
Fa ka data-toggle="dropdown"
link anaa button bi ho na dannan dropdown bi.
- <div class = "a ɛwɔ ase hɔ" >
- <a class = "dropdown-toggle" data-toggle = "dropdown" href = "#" > Nneɛma a wɔde gu fam a ɛkanyan </a>
- <ul class = "dropdown-menu" dwumadie = "menu" aria-a wɔde ahyɛnsodeɛ = "dLabel" >
- ...
- </ul>
- </div> no
Sɛ wopɛ sɛ URL ahorow no kɔ so tra hɔ a, fa data-target
su no di dwuma sen sɛ wode bedi dwuma href="#"
.
- <div class = "a ɛwɔ ase hɔ" >
- <a class = "afiri-a-ɛkɔ soro" id = "dLabel" dwumadie = "button" data-toggle = "afiri ase" data-botaeɛ = "#" href = "/kratafa.html" >
- Dropdown a ɛwɔ hɔ
- <b adesuakuw = "caret" ></b>
- </a>
- <ul class = "dropdown-menu" dwumadie = "menu" aria-a wɔde ahyɛnsodeɛ = "dLabel" >
- ...
- </ul>
- </div> no
Frɛ nsɛm a ɛwɔ ase hɔ no denam JavaScript so:
- $ ( '.asɛm a ɛwɔ ase-toggle' ). a ɛwɔ ase hɔ () .
Ɛnyɛ ebiara
Programmatic api a wɔde toggling menus ma navbar anaa tabbed navigation a wɔde ama.
ScrollSpy plugin no yɛ ma nav botae ahorow a egyina scroll gyinabea so no yɛ foforo ankasa. Twe beae a ɛwɔ navbar no ase no na hwɛ adesuakuw a ɛreyɛ adwuma no nsakrae. Wɔbɛtwe adwene asi nneɛma a ɛwɔ dropdown sub no so nso.
Ad leggings keytar, brunch id adwini apontow dolor adwumayɛfo. Pitchfork yr enim lo-fi ansa na wɔretɔn qui. Tumblr afuw-kɔ-pon sakre hokwan ahorow biara. Anim keffiyeh carles a ɔyɛ ɔkwasea. Velit seitan mcsweeney mfonini dan 3 ɔkraman ɔsram irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui ebia wontee wɔn ho asɛm et cardigan ahotoso sikakorabea culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred aseresɛm biodiesel keffiyeh nsaanodwumayɛfo ullamco consequat.
Veniam marfa abɔgyesɛ skateboard, adipisicing fugiat velit pitchfork abɔgyesɛ. Freegan abɔgyesɛ aliqua cupidat mcsweeney no vero. Cupidatat anan loko nisi, ea helvetica nulla carles. Tattooed cosby sweater aduan lɔre, mcsweeney no quis a ɛnyɛ freegan vinyl. Lo-fi wes anderson +1 a wɔde hyɛ ntade mu. Carles non aesthetic apɔw-mu-teɛteɛ quis gentrify. Brooklyn adipisicing nsaanodwuma beer abadiakyiri keytar deserunt.
Occaecat commodo a wɔde yɛ aduan a ɛyɛ dɛ. Fap nsaanodwuma beer deserunt skateboard ea. Lomo sakre hokwan adipisicing banh mi, velit ea sunt next level locavore biako-mfiase kɔfe wɔ magna veniam. Nkwa a ɛkorɔn id vinyl, echo park consequat quis aliquip banh mi pitchfork. Vero VHS est a wɔde yɛ aduan. Consectetur nisi DIY minim ɔbɔfo bag. Cred ex wɔ, delectus consectetur fanny pack iphone a ɛbɛkɔ so atra hɔ daa.
In incididunt echo park, officia deserunt mcsweeney's proident master cleanse thundercats sapiente veniam. Excepteur VHS elit, proident shoreditch +1 biodiesel laborum craft beer. Single-origin coffee wayfarers irure four loko, cupidatat terry richardson master cleanse. Assumenda you probably haven't heard of them art party fanny pack, tattooed nulla cardigan tempor ad. Proident wolf nesciunt sartorial keffiyeh eu banh mi sustainable. Elit wolf voluptate, lo-fi ea portland before they sold out four loko. Locavore enim nostrud mlkshk brooklyn nesciunt.
Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
Keytar twee blog, culpa ɔbɔfo bag marfa nea ɛte biara delectus aduan lɔre. Sapiente synth id a ɛkyerɛ sɛ obi yɛ ade. Locavore sed helvetica cliche irony, aprannaa a ebia wontee wɔn ho asɛm consequat hoodie gluten-free lo-fi fap aliquip. Labore elit placeat ansa na wɔretɔn awie, terry richardson proident brunch nesciunt quis cosby sweater pariatur keffiyeh ut helvetica adwumfo. Cardigan nsaanodwuma beer seitan a wɔasiesie velit. VHS chambray adwuma no yɛ bere tiaa mu veniam. Anim mollit minim commodo ullamco aprannaa a ɛrebɔ.
Sɛnea ɛbɛyɛ a ɛbɛyɛ mmerɛw sɛ wode scrollspy suban bɛka wo topbar navigation ho no, fa ka data-spy="scroll"
element a wopɛ sɛ wohwɛ so no ho kɛkɛ (mpɛn pii no eyi bɛyɛ nipadua no) na data-target=".navbar"
woapaw nav a wode bedi dwuma. Wobɛpɛ sɛ wode scrollspy a ɛwɔ .nav
component bi di dwuma.
- <nipadua data-spy = "nkyerɛw" data-botae = ".navbar" > ... </nipadua>
Frɛ nhoma mmobɔwee no denam JavaScript so:
- $ ( '#navbar' ). nhoma mmobɔwee () .
<a href="#home">home</a>
ɛsɛ sɛ a ne biribi a ɛwɔ dom no mu te sɛ
<div id="home"></div>
.
Sɛ wode scrollspy di dwuma de ka nneɛma a wode bɛka ho anaa woayi afi DOM no mu ho a, ɛho behia sɛ wofrɛ refresh kwan no te sɛ saa:
- $ ( '[data-spy="nkyerɛwee"]' ). biara ( adwuma () { .
- var $spy = $ ( eyi ). scrollspy ( 'yɛ foforo' ) .
- });
Wobetumi afa data attributes anaa JavaScript so de nneɛma a wobɛpaw no akɔ. Sɛ wopɛ data su ahorow a, fa option din no ka ho data-
, sɛnea ɛwɔ data-offset=""
.
Din | korɔ | mfiaseɛ | nkyerɛmu |
---|---|---|---|
offset a wɔde hyɛ mu | nɔma | 10. 10 | Pixels to offset fi soro bere a worebu gyinabea a scroll no. |
Dwumadie | Nkyerɛmu |
---|---|
yɛ adwuma | Saa adeyɛ yi tow bere biara a ade foforo bi bɛyɛ adwuma denam nhoma mmobɔwee no so. |
Fa tab dwumadie a ɛyɛ ntɛm a ɛyɛ nnam ka ho ma nsakraeɛ fa panes a ɛwɔ mpɔtam hɔ nsɛm mu, mpo denam dropdown menus so.
Raw denim ebia wontee wɔn ho asɛm jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth owura ahotew. Mustache cliche bere tiaa mu, williamsburg carles vegan helvetica. Reprehenderit namkumfoɔ retro keffiyeh daeɛ kyerefoɔ synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Ɔde ne nsa kyerɛɛ ne so, na ɔde ne nsa kyerɛɛ ne so bio. Aliquip placeat salvia a ɔyɛ ɔbarima a ɔpɛ sɛ ɔyɛ biribi. Seitan aliquip quis cardigan american ntade, namtɔnfo voluptate nisi qui.
Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.
Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.
Trust fund seitan letterpress, keytar raw denim keffiyeh etsy adwini apontow ansa na wɔretɔn awie owura tew gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, adwini apontow locavore ɔkraman cliche asetra a ɛkorɔn echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi ansa na wɔretɔn afuw-kɔ-pon VHS viral locavore cosby sweater awie. Lomo ɔkraman viral, abɔgyesɛ readymade aprannaa keffiyeh nsaanodwuma beer marfa abrabɔ pa. Ɔkraman salvia freegan, sartorial keffiyeh echo abɔnten so vegan.
Ma tabable tabs no nyɛ adwuma denam JavaScript so (ɛsɛ sɛ wode tab biara yɛ adwuma mmiako mmiako):
- $ ( '# meTab a' ). klik ( adwuma ( e ) { .
- e . siw Default ano ();
- $ ( eyi ). tab ( 'kyerɛ' );
- }) na .
Wubetumi ayɛ tab ankorankoro adwuma wɔ akwan horow pii so:
- $ ( '# meTab a[href="#nsɛmpa"]' ). tab ( 'kyerɛ' ); // Paw tab no denam din so
- $ ( '# meTab a:nea edi kan' ). tab ( 'kyerɛ' ); // Paw tab a edi kan
- $ ( '# meTab a:a etwa to' ). tab ( 'kyerɛ' ); // Paw tab a etwa to
- $ ( '# meTab li: eq (2) a' ). tab ( 'kyerɛ' ); // Paw tab a ɛto so abiɛsa (0-indexed) .
Wubetumi ama tab anaa pill navigation ayɛ adwuma a worenkyerɛw JavaScript biara denam element bi a wobɛkyerɛ ara kwa data-toggle="tab"
anaasɛ wobɛka so. data-toggle="pill"
Sɛ wode nav
ne nav-tabs
adesua ahorow no ka tab ul
no ho a, ɛbɛma Bootstrap tab no styling no adi dwuma.
- <ul adesuakuw = "nav nav-tabs" >
- <li><a href = "#fie" data-toggle = "tab" > Fie </a></li>
- <li><a href = "#profile" data-toggle = "tab" > Nsɛm a ɛfa ho </a></li>
- <li><a href = "#nkrasɛm" data-toggle = "tab" > Nkrasɛm </a></li>
- <li><a href = "#nhyehyɛe" data-toggle = "tab" > Nsiesiei </a></li>
- </ul>
Ɛma tab element ne nsɛm a ɛwɔ mu no yɛ adwuma. Ɛsɛ sɛ tab nya a data-target
anaasɛ href
targeting a container node wɔ DOM no mu.
- <ul adesuakuw = "nav nav-tabs" id = "meTab" >
- <li adesuakuw = "yɛ adwuma" ><a href = "#fie" > Fie </a></li>
- <li><a href = "#profile" > Nsɛm a ɛfa ho </a></li>
- <li><a href = "#nkrasɛm" > Nkrasɛm </a></li>
- <li><a href = "#nhyehyɛe" > Nsiesiei </a></li>
- </ul>
- <div adesuakuw = "tab-nsɛm" >
- <div adesuakuw = "tab-pane a ɛyɛ adwuma" id = "fie" > ... </div>
- <div adesuakuw = "tab-pane" id = "fael" > ... </div>
- <div adesuakuw = "tab-pane" id = "nkrasɛm" > ... </div>
- <div adesuakuw = "tab-pane" id = "nhyehyɛe" > ... </div>
- </div> no
- <nkyerɛwee>
- $ ( dwumadie () { .
- $ ( '# meTab a:a etwa to' ). tab ( 'kyerɛ' );
- }) na .
- </script>
Dwumadie | Nkyerɛmu |
---|---|
da no adi | Saa adeyɛ yi tow wɔ tab show so, nanso ansa na wɔakyerɛ tab foforo no. Fa event.target ne di dwuma event.relatedTarget fa w’ani si active tab ne active tab a atwam no so (sɛ ɛwɔ hɔ a) sɛnea ɛte biara. |
a wɔakyerɛ | Saa adeyɛ yi tow wɔ tab show so bere a wɔakyerɛ tab bi akyi. Fa event.target ne di dwuma event.relatedTarget fa w’ani si active tab ne active tab a atwam no so (sɛ ɛwɔ hɔ a) sɛnea ɛte biara. |
- $ ( 'a [data-toggle="tab"]' ). on ( 'wɔakyerɛ' , adwuma ( e ) { .
- e . target // tab a wɔayɛ no adwuma
- e . relatedTarget // tab a atwam no
- }) na .
Wɔde jQuery.tipsy plugin a eye kyɛn so a Jason Frame kyerɛwee no na ɛkanyan no; Nnwinnade ho nsɛm yɛ nkyerɛase a wɔayɛ no foforo, a ɛnyɛ mfonini so, ɛde CSS3 di dwuma ma animations, ne data-attributes ma local title storage.
Esiane adwumayɛ nti, adwinnade no ne popover data-apis no yɛ opt in, a ɛkyerɛ sɛ ɛsɛ sɛ w’ankasa wohyɛ ase .
Fa wo nsa hyɛ link ahorow a ɛwɔ ase ha no so na wubehu nnwinnade ho nyansahyɛ ahorow:
Tight pants next level keffiyeh ebia wontee wɔn ho asɛm. Mfonini dan abɔgyesɛ raw denim letterpress vegan ɔbɔfo bag stumptown. Farm-to-table seitan, mcsweeney fixie sustainable quinoa 8-bit american ntade wɔ terry richardson vinyl chambray. Abɔgyesɛ stumptown, cardigans banh mi lomo aprannaa. Tofu biodiesel williamsburg marfa, anan loko mcsweeney no tew vegan chambray ho. A really ironic artisan whatever keytar , scenester afuw-kɔ-pon banksy Austin twitter di freegan cred raw denim biako-mfiase kɔfe viral.
Sɛ wode nnwinnadeɛ ne popovers redi dwuma ne Bootstrap input akuo no a, ɛbɛhia sɛ wo hyehyɛ container
(wɔakyerɛw wɔ aseɛ ha) option no na woakwati nsunsuansoɔ bɔne a wompɛ.
Fa JavaScript so na ɛkanyan adwinnade no:
- $ ( '#nhwɛso' ). adwinnade ho nsɛm ( akwan horow ) .
Wobetumi afa data attributes anaa JavaScript so de nneɛma a wobɛpaw no akɔ. Sɛ wopɛ data su ahorow a, fa option din no ka ho data-
, sɛnea ɛwɔ data-animation=""
.
Din | korɔ | mfiaseɛ | nkyerɛmu |
---|---|---|---|
animation a wɔde yɛ nneɛma | boolean ho asɛm | nokorɛ | fa css fade nsakrae bi di dwuma wɔ adwinnade no ho |
html na ɛwɔ hɔ | boolean ho asɛm | ɛnyɛ ampa | Fa html hyɛ adwinnade no mu. Sɛ ɛyɛ atoro a, wɔde jquery text kwan no bedi dwuma de ahyɛ nsɛm a ɛwɔ dom no mu. Fa text di dwuma sɛ XSS ntua ho asɛm haw wo a. |
a wɔde bɛto hɔ | ahama | dwumadie | 'soro' | sɛnea wɔde adwinnade no si hɔ - soro | ase hɔ | benkum so | nifa |
nea ɔpaw ade | ahoma | ɛnyɛ ampa | Sɛ wɔde selector bi ma a, wɔde tooltip nneɛma bɛhyɛ botae ahorow a wɔakyerɛ no nsa. |
atiti asɛm | ahama | dwumadie | '' . | default title value sɛ `title` tag no nni hɔ a |
nkanyan | ahoma | 'hover focus'. | sɛnea wɔde adwinnade tip no hyɛ ase - klik | hover | adwene a wɔde si biribi so | akwankyerɛ. Hyɛ no nsow sɛ wo case pass trigger mutliple, ahunmu a wɔatew mu, trigger ahorow. |
ka akyi | nɔma | adeɛ | 0 na ɛwɔ hɔ | delay kyerɛ na wɔde tooltip (ms) no sie - no mfa manual trigger type ho Sɛ wɔde nɔma bi ma a, wɔde delay di dwuma wɔ hide/show abien no nyinaa mu Adeɛ nhyehyɛɛ ne: |
ade a wɔde gu mu | ahama | ɛnyɛ ampa | ɛnyɛ ampa | Fa adwinnade no ho nkyerɛkyerɛmu no ka element pɔtee bi ho |
- <a href = "#" data-toggle = "adwinnade ho nkyerɛkyerɛmu" title = "adwinnade a edi kan" > fa wo ho to me so </a>
Fa adwinnade a wɔde di dwuma no bata element ahorow a wɔaboaboa ano ho.
Ɛda element bi adwinnade ho nsɛm adi.
- $ ( '#adeɛ' ). adwinnade ho nsɛm ( 'kyerɛ' ) .
Fa element bi adwinnade ho nsɛm sie.
- $ ( '#adeɛ' ). adwinnade ho nsɛm ( 'hide' ) .
Toggles element bi adwinnade ho nsɛm.
- $ ( '#adeɛ' ). adwinnade ho nsɛm ( 'toggle' ) .
Hide na ɛsɛe element bi adwinnade tip.
- $ ( '#adeɛ' ). adwinnade ho nsɛm ( 'sɛe' ) .
Fa nsɛm nketenkete a wɔde akata so, te sɛ nea ɛwɔ iPad no so, ka element biara a wode bɛfa nsɛm a ɛto so abien no ho. Fa wo nsa hyɛ bɔtn no so na ama popover no ayɛ kɛse. Ɛhwehwɛ sɛ wɔde Tooltip ka ho.
Nneɛma anan wɔ hɔ a wubetumi apaw: atifi, nifa, ase, ne benkum a wɔahyehyɛ no pɛpɛɛpɛ.
Sed posuere consectetur a ɛyɛ fɛ wɔ lobortis ho. Aenean eu leo quam. Pellentesque ornare sem lacinia a ɛwɔ akyi no.
Sed posuere consectetur a ɛyɛ fɛ wɔ lobortis ho. Aenean eu leo quam. Pellentesque ornare sem lacinia a ɛwɔ akyi no.
Sed posuere consectetur a ɛyɛ fɛ wɔ lobortis ho. Aenean eu leo quam. Pellentesque ornare sem lacinia a ɛwɔ akyi no.
Sed posuere consectetur a ɛyɛ fɛ wɔ lobortis ho. Aenean eu leo quam. Pellentesque ornare sem lacinia a ɛwɔ akyi no.
Wɔnnyɛ markup biara a wɔakyerɛ sɛ popovers fi JavaScript ne nsɛm a ɛwɔ data
attribute bi mu.
Ma popovers nyɛ adwuma denam JavaScript so:
- $ ( '#nhwɛso' ). popover ( nneɛma a wobetumi apaw ) .
Wobetumi afa data attributes anaa JavaScript so de nneɛma a wobɛpaw no akɔ. Sɛ wopɛ data su ahorow a, fa option din no ka ho data-
, sɛnea ɛwɔ data-animation=""
.
Din | korɔ | mfiaseɛ | nkyerɛmu |
---|---|---|---|
animation a wɔde yɛ nneɛma | boolean ho asɛm | nokorɛ | fa css fade nsakrae bi di dwuma wɔ adwinnade no ho |
html na ɛwɔ hɔ | boolean ho asɛm | ɛnyɛ ampa | Fa html hyɛ popover no mu. Sɛ ɛyɛ atoro a, wɔde jquery text kwan no bedi dwuma de ahyɛ nsɛm a ɛwɔ dom no mu. Fa text di dwuma sɛ XSS ntua ho asɛm haw wo a. |
a wɔde bɛto hɔ | ahama | dwumadie | 'nifa' | sɛnea wɔde popover no si hɔ - soro | ase hɔ | benkum so | nifa |
nea ɔpaw ade | ahoma | ɛnyɛ ampa | sɛ wɔde selector bi ma a, wɔde tooltip nneɛma bɛhyɛ botae ahorow a wɔakyerɛ no nsa |
nkanyan | ahoma | 'kliki'. | sɛnea popover no fi ase - klik | hover | adwene a wɔde si biribi so | akwankyerɛ |
atiti asɛm | ahama | dwumadie | '' . | default title value sɛ `title` attribute no nni hɔ a |
emu nsɛm | ahama | dwumadie | '' . | default content value sɛ `data-content` su no nni hɔ a |
ka akyi | nɔma | adeɛ | 0 na ɛwɔ hɔ | delay kyerɛ na wɔde sie popover (ms) - no mfa manual trigger type ho Sɛ wɔde nɔma bi ma a, wɔde delay di dwuma wɔ hide/show abien no nyinaa mu Adeɛ nhyehyɛɛ ne: |
ade a wɔde gu mu | ahama | ɛnyɛ ampa | ɛnyɛ ampa | Ɛde popover no ka element pɔtee bi ho |
Esiane adwumayɛ nti, Tooltip ne Popover data-apis no wɔ opt in. Sɛ wopɛ sɛ wode di dwuma a, kyerɛ selector option bi kɛkɛ.
Fi ase popovers ma element ahorow a wɔaboaboa ano.
Ɛda elements popover bi adi.
- $ ( '#adeɛ' ). popover ( 'kyerɛ' ) .
Ɔde elements popover bi siei.
- $ ( '#adeɛ' ). popover ( 'de sie' ) .
Toggles an elements popover bi a ɛwɔ hɔ.
- $ ( '#adeɛ' ). popover ( 'nsakrae' ) .
Hide na ɛsɛe element bi popover.
- $ ( '#adeɛ' ). popover ( 'sɛe ade' ) .
Fa dismiss dwumadie ka kɔkɔbɔ nkra nyinaa ho denam saa plugin yi so.
Sesa eyi ne eyi na san bɔ mmɔden bio. Duis mollis, est a ɛnyɛ commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus no tena ase sɛ ɛyɛ aduru a wɔde yɛ aduan.
Ma kɔkɔbɔ bi a wɔpow no nyɛ adwuma denam JavaScript so:
- $ ( ".kɔbɔ" ). kɔkɔbɔ () .
Fa ka data-dismiss="alert"
wo close button no ho kɛkɛ na ama woanya alert close functionality no ara kwa.
- <a class = "to" data-dismiss = "kɔbɔ" href = "#" > &mmere; </a>
Wraps kɔkɔbɔ nyinaa ne adwumayɛ a ɛbɛn. Sɛ wopɛ sɛ wo kɔkɔbɔ ahorow no animate bere a wɔato mu no a, hwɛ hu sɛ wɔwɔ .fade
ne .in
adesuakuw no a wɔde adi dwuma dedaw wɔ wɔn ho.
Ɛto kɔkɔbɔ bi mu.
- $ ( ".kɔbɔ" ). kɔkɔbɔ ( 'to mu' ) .
Bootstrap no kɔkɔbɔ adesuakuw no da nsɛm kakraa bi a esisi adi ma hooking kɔ kɔkɔbɔ dwumadi mu.
Dwumadie | Nkyerɛmu |
---|---|
to mu | Saa adeyɛ yi tow ntɛm ara bere a close wɔfrɛ instance kwan no. |
wɔato mu | Wɔtow saa adeyɛ yi bere a wɔato kɔkɔbɔ no mu (bɛtwɛn ma css nsakrae ahorow no awie). |
- $ ( '#me-kɔbɔ' ). bind ( 'wɔato mu' , adwuma () { .
- // yɛ biribi...
- }) na .
Nya base styles ne mmoa a ɛyɛ mmerɛw ma collapsible components te sɛ accordions ne navigation.
* Ɛhwehwɛ sɛ wɔde Transitions plugin no ka ho.
Yɛde collapse plugin no dii dwuma no, yɛyɛɛ accordion style widget a ɛnyɛ den:
- <div adesuakuw = "akordeon" id = "akordion2" >
- <div adesuakuw = "accordion-kuw" >
- <div adesuakuw = "accordion-asɛmti" >
- <a class = "accordion-toggle" data-toggle = "abɔso" data-ɔwofo = "#accordion2" href = "#collapseOne" >
- Kuw Ade #1 a Wobetumi Abobɔw
- </a>
- </div> no
- <div id = "collapseOne" class = "accordion-nipadua a ɛhwe ase wɔ" >
- <div adesuakuw = "accordion-mfinimfini" >
- Anim pariatur nsɛm a wɔka kyerɛ...
- </div> no
- </div> no
- </div> no
- <div adesuakuw = "accordion-kuw" >
- <div adesuakuw = "accordion-asɛmti" >
- <a class = "accordion-toggle" data-toggle = "abɔso" data-ɔwofo = "#accordion2" href = "#collapseAbien" >
- Kuw Ade #2 a Wobetumi Abobɔw
- </a>
- </div> no
- <div id = "collapseTwo" class = "accordion-nipadua a ɛhwe ase" >
- <div adesuakuw = "accordion-mfinimfini" >
- Anim pariatur nsɛm a wɔka kyerɛ...
- </div> no
- </div> no
- </div> no
- </div> no
- ...
Wubetumi nso de plugin no adi dwuma a enni accordion markup no. Yɛ button bi toggle element foforo a ɛretrɛw ne nea ɛrebubu.
- <button type = "button" adesuakuw = "btn btn-asiane" data-toggle = "abɔ " data-botae = "#demo" >
- a ɛnyɛ den a wotumi bubu
- </button> no ho
- <div id = "demo" adesuakuw = "ahwe ase wɔ" > ... </div>
Kɛkɛ add data-toggle="collapse"
ne a data-target
to element na automatically de control of a collapsible element. Attribute no data-target
gye css selector a wɔde collapse no bedi dwuma wɔ so. Hwɛ hu sɛ wode adesuakuw no bɛka collapse
element a wotumi bu no ho. Sɛ wopɛ sɛ ɛbue default a, fa adesua foforo no ka ho in
.
Sɛ wode kuw nhyehyɛe a ɛte sɛ accordion bɛka control a wotumi bubu mu ho a, fa data su no ka ho data-parent="#selector"
. Hwɛ demo no na woahu eyi wɔ adeyɛ mu.
Fa nsa yɛ adwuma denam:
- $ ( ".abɔso" ). ahwe ase () .
Wobetumi afa data attributes anaa JavaScript so de nneɛma a wobɛpaw no akɔ. Sɛ wopɛ data su ahorow a, fa option din no ka ho data-
, sɛnea ɛwɔ data-parent=""
.
Din | korɔ | mfiaseɛ | nkyerɛmu |
---|---|---|---|
ɔwofo | nea ɔpaw ade | ɛnyɛ ampa | Sɛ selector a, ɛnde elements a wotumi paapae mu nyinaa wɔ ɔwofo a wɔakyerɛ no ase no bɛto mu bere a wɔakyerɛ saa ade a wotumi boaboa ano yi. (ɛte sɛ atetesɛm mu accordion suban) . |
toggle no | boolean ho asɛm | nokorɛ | Toggles element a ɛyɛ collapsible wɔ invocation so |
Ɛma wo nsɛm no yɛ adwuma sɛ ade a wotumi bu mu. Gye akwan a wubetumi apaw bi tom object
.
- $ ( '#me a wotumi de tow so' ). ahwe ase ({
- toggle : atoro
- }) na .
Toggles a collapsible element ma wɔakyerɛ anaa wɔde asie.
Kyerɛ element bi a ɛtumi hwe ase.
Ɛde element bi a wotumi bubu mu sie.
Bootstrap no collapse adesua no da nsɛm kakraa bi a esisi ma hooking kɔ collapse dwumadi mu adi.
Dwumadie | Nkyerɛmu |
---|---|
da no adi | Saa adeyɛ yi tow ntɛm ara bere a show wɔfrɛ instance kwan no. |
a wɔakyerɛ | Wɔtow saa adeyɛ yi bere a wɔayɛ collapse element bi a ɔde di dwuma no ahu (bɛtwɛn ma css nsakrae ahorow no awie). |
tɛ | Wɔtow saa adeyɛ yi ntɛm ara bere a hide wɔafrɛ ɔkwan no awie no. |
asuma | Wɔtow saa adeyɛ yi bere a wɔde collapse element bi asie nea ɔde di dwuma no (bɛtwɛn ma css nsakrae ahorow no awie). |
- $ ( '#me a wotumi de tow so' ). on ( 'ahintaw' , adwuma () { .
- // yɛ biribi...
- }) na .
Slideshow a ɛwɔ aseɛ ha yi kyerɛ generic plugin ne component a wɔde sakre fa elements te sɛ carousel mu.
- <div id = "meKarousel" adesuakuw = "carousel slide" >
- <ol adesuakuw = "carousel-nkyerɛkyerɛmu" >
- <li data-target = "#myCarousel" data-slide-to = "0" adesuakuw = "yɛ adwuma" ></li>
- <li data-botaeɛ = "#myCarousel" data-slide-kɔ = "1" ></li>
- <li data-botaeɛ = "#myCarousel" data-slide-kɔ = "2" ></li>
- </ol>
- <!-- Carousel nneɛma -->
- <div adesuakuw = "carousel-mu" >
- <div class = "adeɛ a ɛyɛ adwuma" > ... </div>
- <div adesuakuw = "ade" > ... </div>
- <div adesuakuw = "ade" > ... </div>
- </div> no
- <!-- Carousel nav --> na ɛwɔ hɔ
- <a class = "carousel-control benkum" href = "#meCarousel" data-slide = "a edi kan" > ‹ </a>
- <a class = "carousel-control right" href = "#meCarousel" data-slide = "nea edi hɔ" > › </a>
- </div> no
Fa data attributes di dwuma na ama ɛnyɛ den sɛ wobɛhwɛ carousel no gyinabea so. data-slide
gye nsɛmfua titiriw prev
anaa next
, a ɛsakra slide gyinabea no toto ne mprempren gyinabea ho. Sɛnea ɛbɛyɛ a, fa di dwuma data-slide-to
de fa raw slide index kɔ carousel data-slide-to="2"
, a jump's slide gyinabea no kɔ index pɔtee bi a efi ase wɔ 0
.
Frɛ carousel denam nsa so de:
- $ ( '.afiri a wɔde yɛ kar' ). carousel a wɔde yɛ nneɛma () .
Wobetumi afa data su anaa JavaScriptz so apaw nneɛma. Sɛ wopɛ data su ahorow a, fa option din no ka ho data-
, sɛnea ɛwɔ data-interval=""
.
Din | korɔ | mfiaseɛ | nkyerɛmu |
---|---|---|---|
ntamgyinafo | nɔma | 5000 na ɛwɔ hɔ | Bere dodow a ɛsɛ sɛ wɔtwentwɛn so wɔ ade bi a wɔde sakre tu kwan ankasa ntam. Sɛ ɛyɛ atoro a, carousel renkyinkyin ne ho. |
home so | ahoma | "hover" no. | Pauses cycling a carousel no wɔ mouseenter so na ɔsan fi ase cycling a carousel no wɔ mouseleave so. |
Initializes carousel ne optional options object
na ofi ase sakre fa nneɛma mu.
- $ ( '.afiri a wɔde yɛ kar' ). carousel a wɔde yɛ nneɛma ({ .
- ntamgyinafo : 2000
- }) na .
Kyinkyin fa carousel nneɛma no mu fi benkum kɔ nifa.
Siw carousel no kwan sɛ ɛnsɛ sɛ ɔde sakre fa nneɛma mu.
Cycles carousel no kɔ frame pɔtee bi so (0 a egyina so, a ɛte sɛ array).
Kyinkyin kɔ ade a atwam no so.
Kyinkyin kɔ ade a edi hɔ no so.
Bootstrap carousel adesuakuw no da nsɛm abien a esisi ma hooking kɔ carousel dwumadi mu adi.
Dwumadie | Nkyerɛmu |
---|---|
pia fa so | Saa adeyɛ yi tow ntɛm ara bere a slide wɔfrɛ instance kwan no. |
hwirew mu | Wɔtow saa adeyɛ yi bere a carousel no awie ne slide nsakrae no. |
Mfitiaseɛ, ɛnyɛ den sɛ wɔbɛtrɛw mu plugin a ɛma ntɛm yɛ elegant typeaheads a ɛwɔ form text input biara.
- <input type = "nkyerɛwee" data-ma = "typeahead" >
Wobɛpɛ sɛ wo hyehyɛ autocomplete="off"
sɛnea ɛbɛyɛ a browser menu ahorow a wɔahyɛ da ayɛ no renpue wɔ Bootstrap typeahead dropdown no so.
Fa data attributes ka ho na fa kyerɛw element bi a ɛwɔ typeahead dwumadie sɛdeɛ wɔakyerɛ wɔ nhwɛsoɔ a ɛwɔ atifi hɔ no mu.
Frɛ typeahead no de nsa fa:
- $ ( '.kyerɛw anim' ). typeahead () .
Wobetumi afa data attributes anaa JavaScript so de nneɛma a wobɛpaw no akɔ. Sɛ wopɛ data su ahorow a, fa option din no ka ho data-
, sɛnea ɛwɔ data-source=""
.
Din | korɔ | mfiaseɛ | nkyerɛmu |
---|---|---|---|
farebae | array, dwumadie | [ ] . | Data fibea a ɛsɛ sɛ wobisabisa ho asɛm tia. Ebia ɛbɛyɛ nhama a wɔahyehyɛ anaasɛ adwuma bi. Dwumadi no twam nsɛm abien, query botae a ɛwɔ input field no mu ne process callback no. Wobetumi de dwumadie no adi dwuma synchronously denam data fibea no a wɔbɛsan de aba tẽẽ anaasɛ asynchronously denam process callback no akasakasa baako no so. |
nneɛma | nɔma | 8 | Nneɛma dodow a ɛsen biara a ɛsɛ sɛ wɔda no adi wɔ dropdown no mu. |
minNe tenten | nɔma | 1. 1. | Nkyerɛwde tenten a esua koraa a ehia ansa na woahyɛ nyansahyɛ ahorow a wɔde di dwuma wɔ ɔkwan a ɛyɛ adwuma so no ase |
matcher | dwumadie | case a ɛnyɛ den | Ɔkwan a wɔfa so hu sɛ ebia asɛmmisa bi ne ade bi hyia anaa. Gye akyinnyegye biako tom, nea item wɔde bɛsɔ asɛmmisa no ahwɛ. Fa this.query . Sane boolean true sɛ asɛmmisa no yɛ match a. |
sorter | dwumadie | pɛpɛɛpɛ a ɛne ne ho hyia, nkyerɛwde akɛse a ɛyɛ mmerɛw, nkyerɛwde akɛse a ɛnyɛ den |
Ɔkwan a wɔfa so hyehyɛ autocomplete aba no. Gye akyinnyegye biako tom items na ɔwɔ typeahead nhwɛso no scope. Fa mprempren asɛmmisa no kyerɛ this.query . |
updater | dwumadie | san de ade a woapaw no ba | Ɔkwan a wɔfa so san de ade a wɔapaw no ba. Gye akyinnyegye biako tom, na item ne no wɔ typeahead nhwɛso no scope. |
nea ɛtwe adwene si so | dwumadie | si default matches nyinaa so dua | Ɔkwan a wɔfa so si autocomplete aba no so dua. Gye akyinnyegye biako tom item na ɔwɔ typeahead nhwɛso no scope. Ɛsɛ sɛ ɛsan de html ba. |
Ɛhyɛ input bi ase denam typeahead so.
Subnavigation a ɛwɔ benkum so no yɛ live demo a ɛfa affix plugin no ho.
Sɛnea ɛbɛyɛ a ɛbɛyɛ mmerɛw sɛ wode affix suban bɛka element biara ho no, fa ka data-spy="affix"
element a wopɛ sɛ wohwɛ so no ho kɛkɛ. Afei fa offsets di dwuma de kyerɛ bere a ɛsɛ sɛ wodannan element bi pinning on ne off.
- <div data-spy = "affix" data-offset-atifi = "200" > ... </div>
affix
,
affix-top
, ne
affix-bottom
. Kae sɛ wobɛhwɛ ɔwofo bi a obetumi ahwe ase bere a affix no rebɔ mu efisɛ ɛreyi nsɛm afi kratafa no nsu a ɛsen daa no mu.
Frɛ affix plugin no fa JavaScript so:
- $ ( '#navbar' ). affix () no .
Wobetumi afa data attributes anaa JavaScript so de nneɛma a wobɛpaw no akɔ. Sɛ wopɛ data su ahorow a, fa option din no ka ho data-
, sɛnea ɛwɔ data-offset-top="200"
.
Din | korɔ | mfiaseɛ | nkyerɛmu |
---|---|---|---|
offset a wɔde hyɛ mu | nɔma | dwumadie | adeɛ | 10. 10 | Pixels to offset fi screen bere a worebu gyinabea a scroll no. Sɛ wɔde nɔma biako ma a, wɔde offset no bedi dwuma wɔ soro ne benkum nyinaa. Sɛ wopɛ sɛ wutie akwankyerɛ biako, anaasɛ offset soronko pii a, fa ade bi ma kɛkɛ offset: { x: 10 } . Fa dwumadie bi di dwuma berɛ a ɛhia sɛ wode offset ma wɔ ahoɔden so (ɛho wɔ mfasoɔ ma nhyehyɛɛ bi a ɛyɛ mmuaeɛ). |