JavaScript a ɛwɔ hɔ no

Fa Bootstrap no afã horow no ba nkwa mu —seesei de jQuery plugins 13 a wɔahyɛ da ayɛ.

Ti a ɛwɔ soro! Saa docs yi yɛ ma v2.3.2, a ɛnyɛ aban mmoa bio. Hwɛ Bootstrap no fã a aba foforo no!

Ankorankoro anaasɛ wɔaboaboa ano

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.

Data su ahorow

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:

  1. $ ( '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:

  1. $ ( 'nipadua' ). off ( '.akɔbɔ.data-api' ) .

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

  1. $ ( ".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):

  1. $ ( "#meModal" ). modal () // wɔde default ahorow ahyɛ ase
  2. $ ( "#meModal" ). modal ({ keyboard : atoro }) // ahyɛ aseɛ a keyboard biara nni mu
  3. $ ( "#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').

Ntawntawdi Biara Nni Hɔ

Ɛ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ɛ .noConflictplugin a wopɛ sɛ wosan de bo no ba no.

  1. var bootstrapBɔtɔn = $ . fn . bɔtɔn no . noConflict () // san $.fn.button kɔ botae a wɔadi kan de ama no so
  2. $ . fn . bootstrapBtn = bootstrapButton // ma $().bootstrapBtn bootstrap dwumadie no

Nsɛm a esisi

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.

  1. $ ( '#meModal' ). on ( 'kyerɛ' , dwumadie ( e ) { .
  2. (! data ) san ba e . preventDefault () // gyae modal a wɔde bɛkyerɛ
  3. }) na .

Ɛfa nsakrae ahorow ho

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.

Fa nsɛm a wɔakyerɛw di dwuma

Nsakraeɛ plugin no ho nhwɛsoɔ kakra:

  • Sliding anaasɛ fading wɔ modals mu
  • Fading a ɛwɔ tabs no mu
  • Fading out kɔkɔbɔ ahorow
  • Carousel panes a wɔde twetwe nneɛma

Nhwɛso ahorow

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.

Static nhwɛso

Modal a wɔakyerɛ ase a ɛwɔ atiri, nipadua, ne nneyɛe ahorow a wɔahyehyɛ wɔ ase hɔ.

  1. <div adesuakuw = "modal hide fade" >
  2. <div adesuakuw = "modal-atiri" >
  3. <button type = "button" class = "to" data-dismiss = "modal" aria-hidden = "nokware" > &mmere; </button> no ho
  4. <h3> Modal asɛmti </h3>
  5. </div> no
  6. <div adesuakuw = "modal-nipadua" >
  7. <p> Nipadua pa biako... </p>
  8. </div> no
  9. <div adesuakuw = "modal-nan ase" >
  10. <a href = "#" adesuakuw = "btn" > To mu </a>
  11. <a href = "#" class = "btn btn-primary" > Sie nsakraeɛ </a>
  12. </div> no
  13. </div> no

Live demo a ɛwɔ hɔ

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.

  1. <!-- Button a ɛbɛkanyan modal -->
  2. <a href = "#myModal" dwumadie = "bɔtn" adesuakuw = "btn" data-toggle = "modal" > Fi ase demo modal </a>
  3.  
  4. <!-- Modal --> a ɛyɛ nwonwa
  5. <div id = "meModal" adesuakuw = "modal hide fade" tabindex = "-1" dwuma = "nkɔmmɔbɔ" aria-labelledby = "meModalLabel" aria-hidden = "nokware" >
  6. <div adesuakuw = "modal-atiri" >
  7. <button type = "button" class = "to" data-dismiss = "modal" aria-hidden = "nokware" > × </button>
  8. <h3 id = "myModalLabel" > Modal asɛmti </h3>
  9. </div> no
  10. <div adesuakuw = "modal-nipadua" >
  11. <p> Nipadua pa biako... </p>
  12. </div> no
  13. <div adesuakuw = "modal-nan ase" >
  14. <button class = "btn" data-dismiss = "modal" aria-hidden = "nokware" > Ka </button> mu
  15. <button class = "btn btn-primary" > Sie nsakraeɛ </button>
  16. </div> no
  17. </div> no

Sɛnea wɔde di dwuma

Via data su ahorow so

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.

  1. <button type = "button" data-toggle = "modal" data-botae = "#myModal" > Fi ase modal </button>

Ɛdenam JavaScript so

Frɛ modal a ɛwɔ id myModala ɛwɔ JavaScript line biako:

  1. $ ( '#meModal' ). modal ( nneɛma a wobetumi apaw ) .

Nneɛma a wubetumi 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ɛ staticma 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 loadkwan no so na wɔde ahyɛ .modal-body. Sɛ wode data api no redi dwuma a, wubetumi de hreftag no adi dwuma ɔkwan foforo so de akyerɛ akyirikyiri fibea no. Wɔakyerɛ eyi ho nhwɛso wɔ ase ha:

  1. <a data-toggle="modal" href="remote.html" data-target="#modal">click me</a>

Akwan a wɔfa so yɛ

.modal(nneɛma a wobetumi apaw) .

Ɛma wo nsɛm no yɛ adwuma sɛ modal. Gye akwan a wubetumi apaw bi tom object.

  1. $ ( '#meModal' ). ɔkwan a wɔfa so yɛ ade ({
  2. keyboard : atoro
  3. }) na .

.modal('dannan') .

Nsaano toggles a modal.

  1. $ ( '#meModal' ). modal ( 'nsakrae' ) .

.modal('kyerɛ') .

Nsaano bue modal bi.

  1. $ ( '#meModal' ). modal ( 'kyerɛ' ) .

.modal('de sie') .

Nsaano de sie modal bi.

  1. $ ( '#meModal' ). modal ( 'de sie' ) .

Nsɛm a esisi

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 showwɔ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).
Wɔtow saa adeyɛ yi ntɛm ara bere a hidewɔ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).
  1. $ ( '#meModal' ). on ( 'ahintaw' , adwuma () { .
  2. // yɛ biribi...
  3. }) na .

Nhwɛso wɔ navbar mu

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.

@kɛseɛ

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.

@mdo na ɔkyerɛwee

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.

baako

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.

mmienu

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.

three

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 wɔde di dwuma

Via data su ahorow so

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ɔ .navcomponent bi di dwuma.

  1. <nipadua data-spy = "nkyerɛw" data-botae = ".navbar" > ... </nipadua>

Ɛdenam JavaScript so

Frɛ nhoma mmobɔwee no denam JavaScript so:

  1. $ ( '#navbar' ). nhoma mmobɔwee () .
Ti a ɛwɔ soro! Ɛsɛ sɛ Navbar link ahorow no nya id botae ahorow a wobetumi asiesie. Sɛ nhwɛso no, <a href="#home">home</a>ɛsɛ sɛ a ne biribi a ɛwɔ dom no mu te sɛ <div id="home"></div>.

Akwan a wɔfa so yɛ

.scrollspy('yɛ foforo') .

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:

  1. $ ( '[data-spy="nkyerɛwee"]' ). biara ( adwuma () { .
  2. var $spy = $ ( eyi ). scrollspy ( 'yɛ foforo' ) .
  3. });

Nneɛma a wubetumi 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-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.

Nsɛm a esisi

Dwumadie Nkyerɛmu
yɛ adwuma Saa adeyɛ yi tow bere biara a ade foforo bi bɛyɛ adwuma denam nhoma mmobɔwee no so.

Nhwɛso tab ahorow

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.


Sɛnea wɔde di dwuma

Ma tabable tabs no nyɛ adwuma denam JavaScript so (ɛsɛ sɛ wode tab biara yɛ adwuma mmiako mmiako):

  1. $ ( '# meTab a' ). klik ( adwuma ( e ) { .
  2. e . siw Default ano ();
  3. $ ( eyi ). tab ( 'kyerɛ' );
  4. }) na .

Wubetumi ayɛ tab ankorankoro adwuma wɔ akwan horow pii so:

  1. $ ( '# meTab a[href="#nsɛmpa"]' ). tab ( 'kyerɛ' ); // Paw tab no denam din so
  2. $ ( '# meTab a:nea edi kan' ). tab ( 'kyerɛ' ); // Paw tab a edi kan
  3. $ ( '# meTab a:a etwa to' ). tab ( 'kyerɛ' ); // Paw tab a etwa to
  4. $ ( '# meTab li: eq (2) a' ). tab ( 'kyerɛ' ); // Paw tab a ɛto so abiɛsa (0-indexed) .

Markup a wɔde hyɛ agyirae

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 navne nav-tabsadesua ahorow no ka tab ulno ho a, ɛbɛma Bootstrap tab no styling no adi dwuma.

  1. <ul adesuakuw = "nav nav-tabs" >
  2. <li><a href = "#fie" data-toggle = "tab" > Fie </a></li>
  3. <li><a href = "#profile" data-toggle = "tab" > Nsɛm a ɛfa ho </a></li>
  4. <li><a href = "#nkrasɛm" data-toggle = "tab" > Nkrasɛm </a></li>
  5. <li><a href = "#nhyehyɛe" data-toggle = "tab" > Nsiesiei </a></li>
  6. </ul>

Akwan a wɔfa so yɛ

$().tab no ho nsɛm

Ɛma tab element ne nsɛm a ɛwɔ mu no yɛ adwuma. Ɛsɛ sɛ tab nya a data-targetanaasɛ hreftargeting a container node wɔ DOM no mu.

  1. <ul adesuakuw = "nav nav-tabs" id = "meTab" >
  2. <li adesuakuw = "yɛ adwuma" ><a href = "#fie" > Fie </a></li>
  3. <li><a href = "#profile" > Nsɛm a ɛfa ho </a></li>
  4. <li><a href = "#nkrasɛm" > Nkrasɛm </a></li>
  5. <li><a href = "#nhyehyɛe" > Nsiesiei </a></li>
  6. </ul>
  7.  
  8. <div adesuakuw = "tab-nsɛm" >
  9. <div adesuakuw = "tab-pane a ɛyɛ adwuma" id = "fie" > ... </div>
  10. <div adesuakuw = "tab-pane" id = "fael" > ... </div>
  11. <div adesuakuw = "tab-pane" id = "nkrasɛm" > ... </div>
  12. <div adesuakuw = "tab-pane" id = "nhyehyɛe" > ... </div>
  13. </div> no
  14.  
  15. <nkyerɛwee>
  16. $ ( dwumadie () { .
  17. $ ( '# meTab a:a etwa to' ). tab ( 'kyerɛ' );
  18. }) na .
  19. </script>

Nsɛm a esisi

Dwumadie Nkyerɛmu
da no adi Saa adeyɛ yi tow wɔ tab show so, nanso ansa na wɔakyerɛ tab foforo no. Fa event.targetne di dwuma event.relatedTargetfa 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.targetne di dwuma event.relatedTargetfa w’ani si active tab ne active tab a atwam no so (sɛ ɛwɔ hɔ a) sɛnea ɛte biara.
  1. $ ( 'a [data-toggle="tab"]' ). on ( 'wɔakyerɛ' , adwuma ( e ) { .
  2. e . target // tab a wɔayɛ no adwuma
  3. e . relatedTarget // tab a atwam no
  4. }) na .

Nhwɛso ahorow

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

Akwankyerɛ anan

Nnwinnade ho afotu wɔ nsɛm a wɔde hyɛ mu akuw mu

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


Sɛnea wɔde di dwuma

Fa JavaScript so na ɛkanyan adwinnade no:

  1. $ ( '#nhwɛso' ). adwinnade ho nsɛm ( akwan horow ) .

Nneɛma a wubetumi 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ɛ adwinnade no mu. Sɛ ɛyɛ atoro a, wɔde jquery textkwan 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:delay: { show: 500, hide: 100 }

ade a wɔde gu mu ahama | ɛnyɛ ampa ɛnyɛ ampa

Fa adwinnade no ho nkyerɛkyerɛmu no ka element pɔtee bi hocontainer: 'body'

Ti a ɛwɔ soro! Wobetumi akyerɛ akwan foforo a wɔbɛfa so akyerɛ ankorankoro adwinnade ho nkyerɛkyerɛmu denam data su ahorow a wɔde bedi dwuma so.

Markup a wɔde hyɛ agyirae

  1. <a href = "#" data-toggle = "adwinnade ho nkyerɛkyerɛmu" title = "adwinnade a edi kan" > fa wo ho to me so </a>

Akwan a wɔfa so yɛ

$().adwinnade ho nsɛm(a wobɛpaw) .

Fa adwinnade a wɔde di dwuma no bata element ahorow a wɔaboaboa ano ho.

.adwinnade ho nsɛm('kyerɛ') .

Ɛda element bi adwinnade ho nsɛm adi.

  1. $ ( '#adeɛ' ). adwinnade ho nsɛm ( 'kyerɛ' ) .

.adwinnade ho nsɛm('hide') .

Fa element bi adwinnade ho nsɛm sie.

  1. $ ( '#adeɛ' ). adwinnade ho nsɛm ( 'hide' ) .

.adwinnade ho nsɛm('toggle') .

Toggles element bi adwinnade ho nsɛm.

  1. $ ( '#adeɛ' ). adwinnade ho nsɛm ( 'toggle' ) .

.tooltip('sɛe') .

Hide na ɛsɛe element bi adwinnade tip.

  1. $ ( '#adeɛ' ). adwinnade ho nsɛm ( 'sɛe' ) .

Nhwɛso ahorow

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.

Popover a ɛyɛ gyinabea

Nneɛma anan wɔ hɔ a wubetumi apaw: atifi, nifa, ase, ne benkum a wɔahyehyɛ no pɛpɛɛpɛ.

Popover a ɛwɔ soro no

Sed posuere consectetur a ɛyɛ fɛ wɔ lobortis ho. Aenean eu leo ​​quam. Pellentesque ornare sem lacinia a ɛwɔ akyi no.

Popover no yɛ nokware

Sed posuere consectetur a ɛyɛ fɛ wɔ lobortis ho. Aenean eu leo ​​quam. Pellentesque ornare sem lacinia a ɛwɔ akyi no.

Popover ase hɔ

Sed posuere consectetur a ɛyɛ fɛ wɔ lobortis ho. Aenean eu leo ​​quam. Pellentesque ornare sem lacinia a ɛwɔ akyi no.

Popover fii hɔ kɔe

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ɔ dataattribute bi mu.

Live demo a ɛwɔ hɔ

Akwankyerɛ anan


Sɛnea wɔde di dwuma

Ma popovers nyɛ adwuma denam JavaScript so:

  1. $ ( '#nhwɛso' ). popover ( nneɛma a wobetumi apaw ) .

Nneɛma a wubetumi 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 textkwan 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:delay: { show: 500, hide: 100 }

ade a wɔde gu mu ahama | ɛnyɛ ampa ɛnyɛ ampa

Ɛde popover no ka element pɔtee bi hocontainer: 'body'

Ti a ɛwɔ soro! Wobetumi akyerɛ akwan foforo a wɔbɛfa so akyerɛ ankorankoro popovers denam data su ahorow a wɔde bedi dwuma so.

Markup a wɔde hyɛ agyirae

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

Akwan a wɔfa so yɛ

$().popover(nneɛma a wobetumi apaw) .

Fi ase popovers ma element ahorow a wɔaboaboa ano.

.popover('kyerɛ') .

Ɛda elements popover bi adi.

  1. $ ( '#adeɛ' ). popover ( 'kyerɛ' ) .

.popover('de sie') .

Ɔde elements popover bi siei.

  1. $ ( '#adeɛ' ). popover ( 'de sie' ) .

.popover('dannan') .

Toggles an elements popover bi a ɛwɔ hɔ.

  1. $ ( '#adeɛ' ). popover ( 'nsakrae' ) .

.popover('sɛe ade') .

Hide na ɛsɛe element bi popover.

  1. $ ( '#adeɛ' ). popover ( 'sɛe ade' ) .

Nhwɛso a ɛfa kɔkɔbɔ ahorow ho

Fa dismiss dwumadie ka kɔkɔbɔ nkra nyinaa ho denam saa plugin yi so.

Guacamole kronkron! Best check yo self, wo nnyɛ fɛ dodo.

Oh snap! Woanya mfomso bi!

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.

Yɛ saa adeyɛ yi Anaasɛ yɛ eyi


Sɛnea wɔde di dwuma

Ma kɔkɔbɔ bi a wɔpow no nyɛ adwuma denam JavaScript so:

  1. $ ( ".kɔbɔ" ). kɔkɔbɔ () .

Markup a wɔde hyɛ agyirae

Fa ka data-dismiss="alert"wo close button no ho kɛkɛ na ama woanya alert close functionality no ara kwa.

  1. <a class = "to" data-dismiss = "kɔbɔ" href = "#" > &mmere; </a>

Akwan a wɔfa so yɛ

$().ahyɛnsode() .

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ɔ .fadene .inadesuakuw no a wɔde adi dwuma dedaw wɔ wɔn ho.

.alert('to mu') .

Ɛto kɔkɔbɔ bi mu.

  1. $ ( ".kɔbɔ" ). kɔkɔbɔ ( 'to mu' ) .

Nsɛm a esisi

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 closewɔ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).
  1. $ ( '#me-kɔbɔ' ). bind ( 'wɔato mu' , adwuma () { .
  2. // yɛ biribi...
  3. }) na .

Nhwɛso a wɔde di dwuma

Fa bɔton yɛ pii. Control button states anaa yɛ buttons akuo ma components pii te sɛ toolbars.

Ɔman no mu nsɛm

Fa ka data-loading-text="Loading..."ho na wode loading tebea adi dwuma wɔ button bi so.

  1. <button type = "button" class = "btn btn-primary" data-loading-text = "Wɔrehyɛ mu..." > Wɔrehyɛ tebea </button>

Toggle biako pɛ

Fa ka data-toggle="button"ho na ama toggling a ɛwɔ button biako so no ayɛ adwuma.

  1. <button type = "button" class = "btn btn-primary" data-toggle = "bɔtn" > Nsakrae biako </bɔtn>

Hwɛ adaka no mu

Fa ka ho data-toggle="buttons-checkbox"ma checkbox style toggling wɔ btn-group so.

  1. <div adesuakuw = "btn-kuw" data-toggle = "bɔtn-nhwehwɛmu adaka" >
  2. <bɔtn type = "bɔtn" adesuakuw = "btn btn-primary" > Benkum </button>
  3. <button type = "button" adesuakuw = "btn btn-primary" > Mfinimfini </button>
  4. <bɔtn type = "bɔtn" adesuakuw = "btn btn-primary" > Nifa </button>
  5. </div> no

Radio so

Fa ka ho data-toggle="buttons-radio"ma radio kwan so toggling wɔ btn-group so.

  1. <div adesuakuw = "btn-kuw" data-toggle = "bɔtn-radio" >
  2. <bɔtn type = "bɔtn" adesuakuw = "btn btn-primary" > Benkum </button>
  3. <button type = "button" adesuakuw = "btn btn-primary" > Mfinimfini </button>
  4. <bɔtn type = "bɔtn" adesuakuw = "btn btn-primary" > Nifa </button>
  5. </div> no

Sɛnea wɔde di dwuma

Fa JavaScript so ma bɔtɔn ahorow no nyɛ adwuma:

  1. $ ( '.nav-tabs' ). bɔtɔn () .

Markup a wɔde hyɛ agyirae

Data su ahorow no yɛ ade titiriw wɔ button plugin no mu. Hwɛ nhwɛsoɔ koodu a ɛwɔ aseɛ ha yi ma markup ahodoɔ no.

Nneɛma a wubetumi apaw

Ɛnyɛ ebiara

Akwan a wɔfa so yɛ

$ ().button ('dannan') .

Toggles push tebea no. Ɛma button no te sɛ nea wɔayɛ no adwuma.

Ti a ɛwɔ soro! Wubetumi ama auto toggling a ɛwɔ button bi mu no ayɛ adwuma denam data-toggleattribute no a wode bedi dwuma no so.
  1. <bɔtn type = "bɔtɔn" adesuakuw = "btn" data-toggle = "bɔtɔn" > ... </bɔtn>

$().button('asɛm a wɔde gu mu') .

Set button state to loading - ɛmma button no nyɛ adwuma na ɛsesa nsɛm kɔ loading text so. Ɛsɛ sɛ wɔkyerɛkyerɛ nsɛm a wɔde rehyɛ mu no mu wɔ bɔtn element no so denam data su data-loading-textno so .

  1. <button type = "button" class = "btn" data-loading-text = "nneɛma a wɔde rehyɛ mu..." > ... </button>
Ti a ɛwɔ soro! Firefox kɔ so ma tebea a wɔagyae mu no kɔ so wɔ krataafa a wɔde ahyɛ mu no nyinaa mu . Ade a wobetumi asiesie eyi ne sɛ wode autocomplete="off".

$ ().button ('san de si hɔ') .

Sesa button tebea - sesa nsɛm kɔ mfitiase nkyerɛwee so.

$().bɔtn(ahama) .

Resets button state - sesa nsɛm kɔ data biara a wɔakyerɛkyerɛ text tebea mu.

  1. <button type = "button" class = "btn" data-awie-nsɛm = "wɔawie!" > ... </bɔtn> no
  2. <nkyerɛwee>
  3. $ ( '.btn' ) a ɛwɔ hɔ no. button ( 'awie' ) .
  4. </script>

Fa ho

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.

Nhwɛso a ɛfa accordion ho

Yɛde collapse plugin no dii dwuma no, yɛyɛɛ accordion style widget a ɛnyɛ den:

Anim pariatur cliche reprehenderit, enim eiusmod nkwa a ɛkorɔn accusamus terry richardson ad squid. 3 ɔkraman ɔsram officia aute, a ɛnyɛ cupidat skateboard dolor brunch. Aduan lɔre quinoa nesciunt adwumayɛfo eiusmod. Brunch 3 ɔkraman ɔsram tempor, sunt aliqua de anomaa bi to so squid biako-mfitiase kɔfe nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, nsaanodwuma beer adwuma wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur namkumfoɔ vice lomo. Leggings occaecat nsaanodwuma beer afuw-kɔ-pon, raw denim aesthetic synth nesciunt ebia wontee wɔn ho asɛm accusamus labore sustainable VHS.
Anim pariatur cliche reprehenderit, enim eiusmod nkwa a ɛkorɔn accusamus terry richardson ad squid. 3 ɔkraman ɔsram officia aute, a ɛnyɛ cupidat skateboard dolor brunch. Aduan lɔre quinoa nesciunt adwumayɛfo eiusmod. Brunch 3 ɔkraman ɔsram tempor, sunt aliqua de anomaa bi to so squid biako-mfitiase kɔfe nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, nsaanodwuma beer adwuma wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur namkumfoɔ vice lomo. Leggings occaecat nsaanodwuma beer afuw-kɔ-pon, raw denim aesthetic synth nesciunt ebia wontee wɔn ho asɛm accusamus labore sustainable VHS.
Anim pariatur cliche reprehenderit, enim eiusmod nkwa a ɛkorɔn accusamus terry richardson ad squid. 3 ɔkraman ɔsram officia aute, a ɛnyɛ cupidat skateboard dolor brunch. Aduan lɔre quinoa nesciunt adwumayɛfo eiusmod. Brunch 3 ɔkraman ɔsram tempor, sunt aliqua de anomaa bi to so squid biako-mfitiase kɔfe nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, nsaanodwuma beer adwuma wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur namkumfoɔ vice lomo. Leggings occaecat nsaanodwuma beer afuw-kɔ-pon, raw denim aesthetic synth nesciunt ebia wontee wɔn ho asɛm accusamus labore sustainable VHS.
  1. <div adesuakuw = "akordeon" id = "akordion2" >
  2. <div adesuakuw = "accordion-kuw" >
  3. <div adesuakuw = "accordion-asɛmti" >
  4. <a class = "accordion-toggle" data-toggle = "abɔso" data-ɔwofo = "#accordion2" href = "#collapseOne" >
  5. Kuw Ade #1 a Wobetumi Abobɔw
  6. </a>
  7. </div> no
  8. <div id = "collapseOne" class = "accordion-nipadua a ɛhwe ase wɔ" >
  9. <div adesuakuw = "accordion-mfinimfini" >
  10. Anim pariatur nsɛm a wɔka kyerɛ...
  11. </div> no
  12. </div> no
  13. </div> no
  14. <div adesuakuw = "accordion-kuw" >
  15. <div adesuakuw = "accordion-asɛmti" >
  16. <a class = "accordion-toggle" data-toggle = "abɔso" data-ɔwofo = "#accordion2" href = "#collapseAbien" >
  17. Kuw Ade #2 a Wobetumi Abobɔw
  18. </a>
  19. </div> no
  20. <div id = "collapseTwo" class = "accordion-nipadua a ɛhwe ase" >
  21. <div adesuakuw = "accordion-mfinimfini" >
  22. Anim pariatur nsɛm a wɔka kyerɛ...
  23. </div> no
  24. </div> no
  25. </div> no
  26. </div> no
  27. ...

Wubetumi nso de plugin no adi dwuma a enni accordion markup no. Yɛ button bi toggle element foforo a ɛretrɛw ne nea ɛrebubu.

  1. <button type = "button" adesuakuw = "btn btn-asiane" data-toggle = "abɔ " data-botae = "#demo" >
  2. a ɛnyɛ den a wotumi bubu
  3. </button> no ho
  4.  
  5. <div id = "demo" adesuakuw = "ahwe ase wɔ" > ... </div>

Sɛnea wɔde di dwuma

Via data su ahorow so

Kɛkɛ add data-toggle="collapse"ne a data-targetto element na automatically de control of a collapsible element. Attribute no data-targetgye css selector a wɔde collapse no bedi dwuma wɔ so. Hwɛ hu sɛ wode adesuakuw no bɛka collapseelement 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.

Ɛdenam JavaScript so

Fa nsa yɛ adwuma denam:

  1. $ ( ".abɔso" ). ahwe ase () .

Nneɛma a wubetumi 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-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

Akwan a wɔfa so yɛ

.collapse(nneɛma a wobetumi apaw) .

Ɛma wo nsɛm no yɛ adwuma sɛ ade a wotumi bu mu. Gye akwan a wubetumi apaw bi tom object.

  1. $ ( '#me a wotumi de tow so' ). ahwe ase ({
  2. toggle : atoro
  3. }) na .

.collapse('dannan') .

Toggles a collapsible element ma wɔakyerɛ anaa wɔde asie.

.collapse('kyerɛ') .

Kyerɛ element bi a ɛtumi hwe ase.

.collapse('de sie') .

Ɛde element bi a wotumi bubu mu sie.

Nsɛm a esisi

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 showwɔ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).
Wɔtow saa adeyɛ yi ntɛm ara bere a hidewɔ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).
  1. $ ( '#me a wotumi de tow so' ). on ( 'ahintaw' , adwuma () { .
  2. // yɛ biribi...
  3. }) na .

Nhwɛsoɔ

Mfitiaseɛ, ɛnyɛ den sɛ wɔbɛtrɛw mu plugin a ɛma ntɛm yɛ elegant typeaheads a ɛwɔ form text input biara.

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


Sɛnea wɔde di dwuma

Via data su ahorow 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.

Ɛdenam JavaScript so

Frɛ typeahead no de nsa fa:

  1. $ ( '.kyerɛw anim' ). typeahead () .

Nneɛma a wubetumi 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-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, querybotae a ɛwɔ input field no mu ne processcallback no. Wobetumi de dwumadie no adi dwuma synchronously denam data fibea no a wɔbɛsan de aba tẽẽ anaasɛ asynchronously denam processcallback 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 itemwɔde bɛsɔ asɛmmisa no ahwɛ. Fa this.query. Sane boolean truesɛ 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 itemsna ɔ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 itemne 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 itemna ɔwɔ typeahead nhwɛso no scope. Ɛsɛ sɛ ɛsan de html ba.

Akwan a wɔfa so yɛ

.typeahead(nneɛma a wobetumi apaw) .

Ɛhyɛ input bi ase denam typeahead so.

Nhwɛsoɔ

Subnavigation a ɛwɔ benkum so no yɛ live demo a ɛfa affix plugin no ho.


Sɛnea wɔde di dwuma

Via data su ahorow so

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.

  1. <div data-spy = "affix" data-offset-atifi = "200" > ... </div>
Ti a ɛwɔ soro! Ɛsɛ sɛ wohwɛ element bi a wɔde pin ayɛ no gyinabea ne ne wofo a ɔbɛn no ntɛm no suban so. Gyinabea no yɛ nea 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.

Ɛdenam JavaScript so

Frɛ affix plugin no fa JavaScript so:

  1. $ ( '#navbar' ). affix () no .

Nneɛma a wubetumi 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-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ɛ).