I-JavaScript

Yenza izingxenye ze-Bootstrap ziphile—manje enama-plugin e-jQuery ngokwezifiso ayi-13.

Amakhanda phezulu! Lawa madokhumenti awe-v2.3.2, engasasekelwa ngokusemthethweni. Hlola inguqulo yakamuva ye-Bootstrap!

Ngamunye noma ihlanganiswe

Ama-plugin angafakwa ngawodwana (yize amanye edinga ukuncika), noma konke ngesikhathi esisodwa. Kokubili i- bootstrap.js ne- bootstrap.min.js iqukethe wonke ama-plugin efayeleni elilodwa.

Izibaluli zedatha

Ungasebenzisa wonke ama-plugin e-Bootstrap ngokusebenzisa i-markup API ngaphandle kokubhala umugqa owodwa we-JavaScript. Lena i-API yekilasi lokuqala le-Bootstrap futhi kufanele kube ukucabangela kwakho kokuqala lapho usebenzisa i-plugin.

Sekushiwo lokho, kwezinye izimo kungase kufiseleke ukucisha lokhu kusebenza. Ngakho-ke, siphinde futhi sinikeze amandla okukhubaza i-API yesibaluli sedatha ngokukhulula yonke imicimbi emzimbeni ofakwe ``idatha-api'`. Lokhu kubukeka kanje:

  1. $ ( 'umzimba' ). icishiwe ( '.data-api' )

Kungenjalo, ukuze uqondise i-plugin ethile, vele ufake igama le-plugin njengendawo yegama kanye ne-namespace yedatha-api kanje:

  1. $ ( 'umzimba' ). icishiwe ( '.alert.data-api' )

I-Programmatic API

Sikholelwa futhi ukuthi kufanele ukwazi ukusebenzisa wonke ama-plugin e-Bootstrap nge-JavaScript API. Wonke ama-API asesidlangalaleni ayizindlela zodwa, ezisebenzisekayo, futhi abuyisela iqoqo osekwenziwe ngalo.

  1. $ ( ".btn.danger" ). inkinobho ( "guqula" ). addClass ( "amafutha" )

Zonke izindlela kufanele zamukele into ongakhetha kuyo, iyunithi yezinhlamvu eqondise indlela ethile, noma lutho (okuqalisa i-plugin ngokuziphatha okuzenzakalelayo):

  1. $ ( "#myModal" ). i -modal () // iqaliswe ngokuzenzakalelayo
  2. $ ( "#myModal" ). i-modal ({ keyboard : false }) // iqaliswe ngaphandle kwekhibhodi
  3. $ ( "#myModal" ). i -modal ( 'show' ) // iqalisa futhi icele ibonakale ngokushesha

I-plugin ngayinye iphinda iveze umakhi wayo ongahluziwe esakhiweni `soMakhi`: $.fn.popover.Constructor. Uma ungathanda ukuthola isibonelo esithile se-plugin, sithole ngokuqondile entweni: $('[rel=popover]').data('popover').

Akukho Ukungqubuzana

Kwesinye isikhathi kuyadingeka ukusebenzisa ama-plugin e-Bootstrap nezinye izinhlaka ze-UI. Kulezi zimo, ukungqubuzana kwendawo yamagama kungenzeka ngezikhathi ezithile. Uma lokhu kwenzeka, ungashayela .noConflicti-plugin ofisa ukubuyisela inani layo.

  1. var bootstrapButton = $ . fn . inkinobho . noConflict () // buyisela inkinobho engu-$.fn. enanini elinikezwe ngaphambilini
  2. $ . fn . i -bootstrapBtn = i -bootstrapButton // nika i-$().bootstrapBtn ukusebenza kwe-bootstrap

Imicimbi

I-Bootstrap inikeza imicimbi yangokwezifiso yezenzo eziningi ezihlukile ze-plugin. Ngokuvamile, lezi ziza ngendlela engapheli kanye nenkathi edlule - lapho okungapheli (isib. show) kuqalwa ekuqaleni komcimbi, futhi isimo saso sokuhlanganyela esidlule (isib. shown) siyisiqalo lapho kuqedwa isenzo.

Yonke imicimbi engapheli ihlinzeka ngokusebenza kokuvimbelaOkuzenzakalelayo. Lokhu kunikeza ikhono lokumisa ukwenziwa kwesenzo ngaphambi kokuthi siqale.

  1. $ ( '#MyModal' ). ku ( 'show' , umsebenzi ( e ) {
  2. uma (! idatha ) ibuyisela e . preventDefault () // imisa i-modal ekubonisweni
  3. })

Mayelana noshintsho

Ukuze uthole imiphumela elula yoshintsho, faka i -bootstrap-transition.js kanye eceleni kwamanye amafayela e-JS. Uma usebenzisa i-comiled (noma minified) bootstrap.js , asikho isidingo sokufaka lokhu—sekukhona kakade.

Sebenzisa amacala

Izibonelo ezimbalwa ze-plugin yoshintsho:

  • Ukushelela noma ukufiphala kumamodeli
  • Ukufiphala kwamathebhu
  • Iyafiphala izexwayiso
  • Amafasitelana e-carousel ashelelayo

Izibonelo

Ama-modal ayahlelwa, kodwa aguquguqukayo, imiyalo yengxoxo enobuncane bokusebenza obudingekayo kanye nokuzenzakalelayo okuhlakaniphile.

Isibonelo esiqinile

I-modal enikeziwe enesihloko, umzimba, nesethi yezenzo kunyaweni.

  1. <div class = "modal hide fade" >
  2. <div class = "modal-header" >
  3. <button type = "button" class = "close" data-dismiss = "modal" aria-hidden = "true" > × </inkinobho>
  4. <h3> Unhlokweni we-Modal </h3>
  5. </div>
  6. <div class = "modal-body" >
  7. <p> Umzimba owodwa omuhle… </p>
  8. </div>
  9. <div class = "modal-footer" >
  10. <a href = "#" class = "btn"> Vala </a> _
  11. <a href = "#" class = "btn btn-primary" > Londoloza izinguquko </a>
  12. </div>
  13. </div>

Idemo ebukhoma

Guqula i-modal usebenzisa i-JavaScript ngokuchofoza inkinobho engezansi. Izoshelela phansi bese ifiphala kusukela phezulu kwekhasi.

  1. <!-- Inkinobho yokuqalisa i-modal -->
  2. <a href = "#myModal" role = "button" class = "btn" data-toggle = "modal" > Yethula imodeli yedemo </a>
  3.  
  4. <!-- Imodeli -->
  5. <div id = "myModal" class = "modal hide fade" tabindex = "-1" role = "dialog" aria-labelledby = "myModalLabel" aria-hidden = "true" >
  6. <div class = "modal-header" >
  7. <button type = "button" class = "close" data-dismiss = "modal" aria-hidden = "true" > × </button>
  8. <h3 id = "myModalLabel" > Unhlokweni wemodeli </h3>
  9. </div>
  10. <div class = "modal-body" >
  11. <p> Umzimba owodwa omuhle… </p>
  12. </div>
  13. <div class = "modal-footer" >
  14. <button class = "btn" data-dismiss = "modal" aria-hidden = "true" > Vala </button>
  15. <button class = "btn btn-primary" > Londoloza izinguquko </inkinobho>
  16. </div>
  17. </div>

Ukusetshenziswa

Ngezibaluli zedatha

Yenza kusebenze i-modal ngaphandle kokubhala i-JavaScript. Misa data-toggle="modal"into yesilawuli, njengenkinobho, kanye ne-a data-target="#foo"noma href="#foo"ukuze uqondise i-modal ethile ukuze uyiguqule.

  1. <button type = "button" data-toggle = "modal" data-target = "#myModal" > Imodi yokwethula </button>

Nge-JavaScript

Shayela i-modal ene-id myModalenomugqa owodwa we-JavaScript:

  1. $ ( '#MyModal' ). imodeli ( izinketho )

Izinketho

Izinketho zingadluliswa ngezibaluli zedatha noma i-JavaScript. Ukuze uthole izibaluli zedatha, faka igama lenketho kokuthi data-, njengaku data-backdrop="".

Igama uhlobo okuzenzakalelayo incazelo
okwasemuva boolean iqiniso Ifaka i-elementi ye-modal-backdrop. Noma, cacisa staticokwasemuva okungavali i-modal lapho uchofozwa.
ikhibhodi boolean iqiniso Ivala i-modal lapho ukhiye we-escape ucindezelwa
umbukiso boolean iqiniso Ibonisa i-modal lapho iqaliswa.
kude indlela amanga

Uma i-url ekude inikeziwe, okuqukethwe kuzolayishwa ngendlela ye-jQuery loadfuthi kufakwe kufayela le- .modal-body. Uma usebenzisa i-api yedatha, ungasebenzisa hrefumaka ukuze ucacise umthombo wesilawuli kude. Isibonelo salokhu sikhonjiswe ngezansi:

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

Izindlela

.modal(izinketho)

Yenza okuqukethwe kwakho kusebenze njengemodeli. Yamukela izinketho ozikhethela object.

  1. $ ( '#MyModal' ). imodeli ({
  2. ikhibhodi : amanga
  3. })

.modal('guqula')

Iguqula ngokwenza i-modal.

  1. $ ( '#MyModal' ). i-modal ( 'guqula' )

.modal('show')

Ivula mathupha i-modal.

  1. $ ( '#MyModal' ). imodeli ( 'show' )

.imodeli('fihla')

Ifihla i-modal ngokwenza.

  1. $ ( '#MyModal' ). i-modal ( 'fihla' )

Imicimbi

Ikilasi le-modal ye-Bootstrap lidalula imicimbi embalwa ukuze ixhume ekusebenzeni kwe-modal.

Umcimbi Incazelo
umbukiso Lo mcimbi uvutha ngokushesha lapho showindlela yesibonelo ibizwa.
kubonisiwe Lo mcimbi uxoshwa lapho i-modal yenziwe yabonakala kumsebenzisi (izolinda ukuthi izinguquko ze-css ziqedele).
fihla Lo mcimbi uxoshwa ngokushesha lapho hideindlela yesibonelo ibizwa.
kufihliwe Lo mcimbi uxoshwa lapho i-modal isiqedile ukufihlwa kumsebenzisi (izolinda ukuthi izinguquko ze-css ziqedele).
  1. $ ( '#MyModal' ). ku ( 'kufihliwe' , umsebenzi () {
  2. // enza into…
  3. })

Isibonelo ku-navbar

I-plugin ye-ScrollSpy ingeyokuvuselela ngokuzenzakalelayo okuhlosiwe kwe-nav ngokusekelwe endaweni yokuskrola. Skrola indawo engezansi kwe-navbar bese ubuka ukuguquka kwekilasi elisebenzayo. Izinto ezincanyana zokwehla zizogqanyiswa nazo.

@amafutha

I-Ad leggings keytar, i-brunch id art party dolor labore. I-Pitchfork ineminyaka engu-nim lo-fi ngaphambi kokuthi bathengise yonke into. Amalungelo ebhayisikili e-Tumblr epulazini ukuya etafuleni noma yini. I-Cardigan ene-anim keffiyeh carles. Indlwana yezithombe ka-Velit seitan mcsweeney 3 wolf moon irure. Ijezi le-Cosby lomo jean shorts, i-williamsburg hoodie minim qui cishe awukaze uzwe ngazo et cardigan trust fund culpa biodiesel wes anderson aesthetic. U-Nihil one-tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.

@mdo

Veniam marfa amadevu skateboard, adipisicing fugiat velit pitchfork intshebe. Freegan intshebe aliqua cupidatat mcsweeney's vero. Cupidatat ezine loko nisi, ea helvetica nulla carles. Iloli lokudla elifakwe ijezi le-cosby, i-mcsweeney's quis non freegan vinyl. I-Lo-fi wes anderson +1 sartorial. I-Carles non-aesthetic exercitation quis gentrify. I-Brooklyn adipisicing craft beer vice keytar deserunt.

eyodwa

I-Occaecat commodo aliqua deelectus. I-Fap craft beer deserunt skateboard ea. Amalungelo ebhayisikili e-Lomo adipisicing banh mi, velit ea sunt next level locavore ikhofi yemvelaphi eyodwa e-magna veniam. I-vinyl id yempilo ephezulu, i-echo park consequat quis aliquip banh mi pitchfork. Vero VHS est adipisicing. Consectetur nisi DIY minim messenger bag. I-Cred ex in, i-iphone eqhubekayo deelectus consectetur fanny pack.

ezimbili

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 messenger bag marfa whatever deelectus food truck. Sapiente synth id imaginenda. I-Locavore sed helvetica cliche irony, ama-thundercats cishe awukaze uzwe ngawo consequat hoodie gluten-free lo-fi fap aliquip. I-Labore elit placeat ngaphambi kokuba ithengiswe, u-terry richardson proident brunch nesciunt quis cosby sweater pariatur keffiyeh ut helvetica artisan. I-Cardigan craft beer seitan readymade velit. I-VHS chambray laboris tempor veniam. Anim mollit minim commodo ullamco thundercats.


Ukusetshenziswa

Ngezibaluli zedatha

Ukwengeza kalula ukuziphatha kwe-scrollspy ekuzulazuleni kwe data-spy="scroll"-topbar yakho, vele ungeze entweni ofuna ukuyihlola (imvamisa lokhu kuzoba umzimba) data-target=".navbar"nokukhetha ukuthi iyiphi i-nav ongayisebenzisa. Uzofuna ukusebenzisa i-scrollspy nengxenye .nav.

  1. <body data-spy = "scroll" data-target = ".navbar" > ... </body>

Nge-JavaScript

Shayela i-scrollspy nge-JavaScript:

  1. $ ( '#navbar' ). scrollspy ()
Amakhanda phezulu! Izixhumanisi ze-Navbar kufanele zibe neziqondiso ze-id ezingaxazululeka. Isibonelo, i-a <a href="#home">home</a>must ihambisane nento ethile edomini efana <div id="home"></div>.

Izindlela

.scrollspy('refresh')

Uma usebenzisa i-scrollspy ngokuhambisana nokwengeza noma ukususa izakhi ku-DOM, uzodinga ukushayela indlela yokuvuselela kanje:

  1. $ ( '[data-spy="scroll"]' ). ngakunye ( umsebenzi () {
  2. var $spy = $ ( lokhu ). scrollspy ( 'refresh' )
  3. });

Izinketho

Izinketho zingadluliswa ngezibaluli zedatha noma i-JavaScript. Ukuze uthole izibaluli zedatha, faka igama lenketho kokuthi data-, njengaku data-offset="".

Igama uhlobo okuzenzakalelayo incazelo
offset inombolo 10 Amaphikseli okufanele uwasuse ukusuka phezulu uma ubala indawo yokuskrola.

Imicimbi

Umcimbi Incazelo
vula Lo mcimbi uvutha noma nini lapho into entsha yenziwa isebenze i-scrollspy.

Amathebhu ayisibonelo

Engeza ukusebenza kwethebhu esheshayo, eguqukayo ukuze udlule kumafasitelana wokuqukethwe kwasendaweni, ngisho namamenyu okwehlayo.

I-denim eluhlaza cishe awuzange uzwe ngabo izikhindi ze-jean Austin. I-Nesciunt tofu stumptown aliqua, i-retro synth master cleanse. Amadevu cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Ijezi le-Cosby eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher 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.


Ukusetshenziswa

Nika amandla amathebhu aphathekayo nge-JavaScript (ithebhu ngayinye idinga ukwenziwa isebenze ngayodwana):

  1. $ ( '#myTab a' ). chofoza ( umsebenzi ( e ) {
  2. e . vimbelaOkuzenzakalelayo ();
  3. $ ( lokhu ). ithebhu ( 'show' );
  4. })

Ungavula amathebhu ngamanye ngezindlela ezimbalwa:

  1. $ ( '#myTab a[href="#profile"]' ). ithebhu ( 'show' ); // Khetha ithebhu ngegama
  2. $ ( '#myTab a:first' ). ithebhu ( 'show' ); // Khetha ithebhu yokuqala
  3. $ ( '#myTab a:last' ). ithebhu ( 'show' ); // Khetha ithebhu yokugcina
  4. $ ( '#myTab li:eq(2) a' ). ithebhu ( 'show' ); // Khetha ithebhu yesithathu (0-inkomba)

Imakhaphu

Ungakwazi ukuvula ithebhu noma ukuzulazula kwephilisi ngaphandle kokubhala noma iyiphi i-JavaScript ngokucacisa data-toggle="tab"noma ngento data-toggle="pill"ethile. Ukwengeza i- navkanye nav-tabsnamakilasi kuthebhu ulkuzosebenzisa isitayela sethebhu ye-Bootstrap.

  1. <ul class = "nav-tabs" >
  2. <li><a href = "#home" data-toggle = "tab"> Ikhaya </a></li >
  3. <li><a href = "#profile" data-toggle = "tab"> Iphrofayili </a></li >
  4. <li><a href = "#messages" data-toggle = "tab"> Imilayezo </a></li >
  5. <li><a href = "#settings" data-toggle = "tab"> Izilungiselelo </a></li >
  6. </ul>

Izindlela

$().ithebhu

Yenza i-elementi yethebhu isebenze nesiqukathi sokuqukethwe. Ithebhu kufanele ibe no-a data-targetnoma i href-container node ku-DOM.

  1. <ul class = "nav nav-tabs" id = "myTab" >
  2. <li class = "active" ><a href = "#home"> Ikhaya </a></li >
  3. <li > <a href = "#iphrofayili"> Iphrofayili </a></li>
  4. <li><a href = "#imiyalezo" > Imilayezo </a></li>
  5. <li > <a href = "#settings"> Izilungiselelo </a></li>
  6. </ul>
  7.  
  8. <div class = "ithebhu-okuqukethwe" >
  9. <div class = "i-tab-pane esebenzayo" id = "ikhaya" > ... </div>
  10. <div class = "tab-pane" id = "profile" > ... </div>
  11. <div class = "tab-pane" id = "imiyalezo" > ... </div>
  12. <div class = "tab-pane" id = "izilungiselelo" > ... </div>
  13. </div>
  14.  
  15. <script>
  16. $ ( umsebenzi () {
  17. $ ( '#myTab a:last' ). ithebhu ( 'show' );
  18. })
  19. </script>

Imicimbi

Umcimbi Incazelo
umbukiso Lo mcimbi uvutha embukisweni wethebhu, kodwa ngaphambi kokuthi kuboniswe ithebhu entsha. Sebenzisa event.targetfuthi event.relatedTargetuqondise ithebhu esebenzayo kanye nethebhu esebenzayo yangaphambilini (uma ikhona) ngokulandelanayo.
kubonisiwe Lo mcimbi uvutha embukisweni wethebhu ngemva kokuthi ithebhu isibonisiwe. Sebenzisa event.targetfuthi event.relatedTargetuqondise ithebhu esebenzayo kanye nethebhu esebenzayo yangaphambilini (uma ikhona) ngokulandelanayo.
  1. $ ( 'a[data-toggle="tab"]' ). ku ( 'kubonisiwe' , umsebenzi ( e ) {
  2. e . target // ithebhu evuliwe
  3. e . relatedTarget // ithebhu yangaphambilini
  4. })

Izibonelo

Igqugquzelwe i-plugin enhle kakhulu ye-jQuery.tipsy ebhalwe ngu-Jason Frame; Amathuluzi ayinguqulo ebuyekeziwe, engancikile ezithombeni, sebenzisa i-CSS3 ukuze uthole ukugqwayiza, kanye nezibaluli zedatha zokulondoloza isihloko sendawo.

Ngenxa yezizathu zokusebenza, ithiphu yamathuluzi kanye ne-popover data-apis zingena, okusho ukuthi kufanele uziqalise ngokwakho .

Hambisa phezulu kwezixhumanisi ezingezansi ukuze ubone amathuluzi:

Amabhulukwe aqinile ezingeni elilandelayo keffiyeh cishe awuzwanga ngawo. Photo booth intshebe eluhlaza yedenim letterpress vegan messenger bag stumptown. Isambatho se-farm-to-table seitan, i-mcsweeney's fixie sustainable quinoa 8-bit american apparel ine- terry richardson vinyl chambray. Izintshebe stumptown, cardigans banh mi lomo thundercats. I-Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. Ingcweti ehlekisayo ngempela whatever keytar , i-movie-to-table banksy Austin twitter handle freegan cred raw denim single-origin coffee viral.

Izikhombisi-ndlela ezine

Amathuluzi emaqenjini okokufaka

Uma usebenzisa amathiphu wamathuluzi nama-popover ngamaqembu okufaka we-Bootstrap, kuzodingeka ukuthi usethe containerinketho (ebhalwe ngezansi) ukuze ugweme imiphumela emibi engadingeki.


Ukusetshenziswa

Qalisa ithiphu yamathuluzi nge-JavaScript:

  1. $ ( '#isibonelo' ). ithiphu ( izinketho )

Izinketho

Izinketho zingadluliswa ngezibaluli zedatha noma i-JavaScript. Ukuze uthole izibaluli zedatha, faka igama lenketho kokuthi data-, njengaku data-animation="".

Igama uhlobo okuzenzakalelayo incazelo
izithombe boolean iqiniso sebenzisa inguquko ye-css fade ethiphu yamathuluzi
html boolean amanga Faka i-html ethiphu yamathuluzi. Uma kungamanga, indlela ye-jquery textizosetshenziswa ukufaka okuqukethwe ku-dom. Sebenzisa umbhalo uma ukhathazekile ngokuhlaselwa kwe-XSS.
ukubekwa umucu | umsebenzi 'phezulu' indlela yokubeka ithiphu yamathuluzi - phezulu | phansi | kwesokunxele | kwesokudla
isikhethi umucu amanga Uma kunikezwa isikhethi, izinto zethiphu yamathuluzi zizodluliselwa kulokho okuhlosiwe okucacisiwe.
isihloko umucu | umsebenzi '' inani lesihloko elizenzakalelayo uma umaka `wesihloko` ungekho
inhlamvu umucu 'hover focus' ukuthi ithiphu yamathuluzi icushwa kanjani - chofoza | hamba | gxila | imanuwali. Qaphela ukuthi i-case pass trigger mutliple, isikhala esihlukanisiwe, izinhlobo ze-trigger.
ukubambezela inombolo | into 0

ukubambezeleka ukubonisa nokufihla ithiphu yamathuluzi (ms) - ayisebenzi ohlotsheni lwesicuphi sesandla

Uma inombolo inikezwa, ukubambezeleka kusetshenziswa kukho kokubili ukufihla/umbukiso

Isakhiwo sento sithi:delay: { show: 500, hide: 100 }

isitsha umucu | amanga amanga

Yengeza ithiphu entweni ethilecontainer: 'body'

Amakhanda phezulu!Izinketho zamathiphu angawodwana zingachazwa ngokusetshenziswa kwezibaluli zedatha.

Imakhaphu

  1. <a href = "#" data-toggle = "tooltip" title = "ithulusi lokuqala"> hambisa phezu kwami ​​</a>

Izindlela

$().ithulusi(izinketho)

Inamathisela isibambi sethulithiphu eqoqweni le-elementi.

.ithiphu yethuluzi('show')

Iveza ithulithiphu yento ethile.

  1. $ ( '#element' ). ithiphu yamathuluzi ( 'show' )

.ithiphu yethuluzi('fihla')

Ifihla ithiphu yento ethile.

  1. $ ( '#element' ). ithiphu yamathuluzi ( 'fihla' )

.ithiphu yethuluzi('guqula')

Iguqula ithiphu lethuluzi le-elementi.

  1. $ ( '#element' ). ithiphu yamathuluzi ( 'guqula' )

.tooltip('destroy')

Ifihla futhi ibhubhise ithiphu yento ethile.

  1. $ ( '#element' ). ithiphu yamathuluzi ( 'destroy' )

Izibonelo

Engeza izimbondela ezincane zokuqukethwe, njengalezo eziku-iPad, kunoma iyiphi into ukuze uthole ulwazi lwesibili lwezindlu. Hambisa phezulu kwenkinobho ukuze uqalise i-popover. Idinga ithiphu yamathuluzi ukuthi ifakwe.

I-popover emile

Kunezinketho ezine ezitholakalayo: kuqondaniswe phezulu, kwesokudla, phansi, nesobunxele.

I-Popover top

Sed posuere consectetur est at lobortis. Aenean eu leo ​​quam. I-Pellentesque ornare sem lacinia quam venenatis vestibulum.

I-Popover kwesokudla

Sed posuere consectetur est at lobortis. Aenean eu leo ​​quam. I-Pellentesque ornare sem lacinia quam venenatis vestibulum.

I-Popover bottom

Sed posuere consectetur est at lobortis. Aenean eu leo ​​quam. I-Pellentesque ornare sem lacinia quam venenatis vestibulum.

U-Popover uhambile

Sed posuere consectetur est at lobortis. Aenean eu leo ​​quam. I-Pellentesque ornare sem lacinia quam venenatis vestibulum.

Akukho makhaphu aboniswa njengama-popover akhiqizwa ku-JavaScript nokuqukethwe ngaphakathi datakwesibaluli.

Idemo ebukhoma

Izikhombisi-ndlela ezine


Ukusetshenziswa

Nika amandla ama-popovers nge-JavaScript:

  1. $ ( '#isibonelo' ). i- popover ( izinketho )

Izinketho

Izinketho zingadluliswa ngezibaluli zedatha noma i-JavaScript. Ukuze uthole izibaluli zedatha, faka igama lenketho kokuthi data-, njengaku data-animation="".

Igama uhlobo okuzenzakalelayo incazelo
izithombe boolean iqiniso sebenzisa inguquko ye-css fade ethiphu yamathuluzi
html boolean amanga Faka i-html ku-popover. Uma kungamanga, indlela ye-jquery textizosetshenziswa ukufaka okuqukethwe ku-dom. Sebenzisa umbhalo uma ukhathazekile ngokuhlaselwa kwe-XSS.
ukubekwa umucu | umsebenzi 'kwesokudla' indlela yokubeka i-popover - phezulu | phansi | kwesokunxele | kwesokudla
isikhethi umucu amanga uma kunikezwa isikhethi, izinto zethulithiphu zizodluliselwa kulokho okuhlosiwe
inhlamvu umucu 'chofoza' i-popover iqalwa kanjani - chofoza | hamba | gxila | imanuwali
isihloko umucu | umsebenzi '' inani lesihloko elizenzakalelayo uma isibaluli `sesihloko` singekho
okuqukethwe umucu | umsebenzi '' inani lokuqukethwe elizenzakalelayo uma isibaluli `sokuqukethwe kwedatha` singekho
ukubambezela inombolo | into 0

ukubambezeleka ukubonisa nokufihla i-popover (ms) - ayisebenzi ohlotsheni lwe-trigger okwenziwa ngesandla

Uma inombolo inikezwa, ukubambezeleka kusetshenziswa kukho kokubili ukufihla/umbukiso

Isakhiwo sento sithi:delay: { show: 500, hide: 100 }

isitsha umucu | amanga amanga

Yengeza i-popover kusici esithilecontainer: 'body'

Amakhanda phezulu! Izinketho ze-popover ezingazodwana zingacaciswa ngokusebenzisa izibaluli zedatha.

Imakhaphu

Ngezizathu zokusebenza, Ithulithiphu kanye ne-Popover data-apis zingena. Uma ungathanda ukuzisebenzisa vele ucacise inketho yesikhethi.

Izindlela

$().i-popover(izinketho)

Iqalisa ama-popover eqoqo le-elementi.

.popover('show')

Iveza i-popover yama-elementi.

  1. $ ( '#element' ). popover ( 'show' )

.popover('fihla')

Ifihla i-popover yama-elementi.

  1. $ ( '#element' ). popover ( 'fihla' )

.popover('guqula')

Iguqula i-popover yezinto.

  1. $ ( '#element' ). i- popover ( 'guqula' )

.popover('destroy')

Ifihla futhi icekele phansi i-popover yento.

  1. $ ( '#element' ). i- popover ( 'destroy' )

Izexwayiso eziyisibonelo

Engeza umsebenzi wokucashisa kuyo yonke imilayezo yesixwayiso enale plugin.

I-guacamole engcwele! Kungcono uzihlole kahle, awubukeki umuhle kakhulu.

Hawu! Unephutha!

Shintsha lokhu nalokhu bese uzama futhi. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. I-Cras mattis consectetur purus sit amet fermentum.

Thatha lesi senzo Noma yenza lokhu


Ukusetshenziswa

Nika amandla ukuchithwa kwesexwayiso nge-JavaScript:

  1. $ ( ".isaziso" ). qaphela ()

Imakhaphu

Vele ungeze data-dismiss="alert"enkinobheni yakho yokuvala ukuze unikeze ngokuzenzakalelayo ukusebenza kwesexwayiso sokuvala.

  1. <a class = "close" data-dismiss = "alert" href = "#" > × </a>

Izindlela

$().isaziso()

Igoqa zonke izexwayiso ngokusebenza okuseduze. Ukuze izexwayiso zakho zigqwayize uma zivaliwe, qiniseka ukuthi sezisetshenzisiwe .fadefuthi .innekilasi kuzo.

.sexwayiso('vala')

Ivala isexwayiso.

  1. $ ( ".isaziso" ). isixwayiso ( 'vala' )

Imicimbi

Ikilasi lesexwayiso le-Bootstrap lidalula imicimbi embalwa ukuze ixhumeke ekusebenzeni kwesixwayiso.

Umcimbi Incazelo
vala Lo mcimbi uvutha ngokushesha lapho closeindlela yesibonelo ibizwa.
ivaliwe Lo mcimbi uyaxoshwa uma isaziso sivaliwe (sizolinda ukuthi izinguquko ze-css ziqedele).
  1. $ ( '#isaziso sami' ). bopha ( 'kuvaliwe' , umsebenzi () {
  2. // enza into…
  3. })

Isibonelo sokusetshenziswa

Yenza okwengeziwe ngezinkinobho. Inkinobho yokulawula ithi noma dala amaqembu ezinkinobho zezingxenye ezengeziwe njengamabha wamathuluzi.

Okushoyo

Engeza data-loading-text="Loading..."ukuze usebenzise isimo sokulayisha enkinobho.

  1. <button type = "button" class = "btn btn-primary" data-loading-text = "Iyalayisha..." > Isimo sokulayisha </button>

Ukuguqula okukodwa

Engeza data-toggle="button"ukuze wenze kusebenze ukuguqula inkinobho eyodwa.

  1. <button type = "button" class = "btn btn-primary" data-toggle = "inkinobho" > Ukuguqula Okukodwa </inkinobho>

Ibhokisi lokuhlola

Engeza data-toggle="buttons-checkbox"ukuguqula isitayela sebhokisi lokuhlola ku-btn-group.

  1. <div class = "btn-group" data-toggle = "ibhokisi lokuhlola lezinkinobho" >
  2. <button type = "button" class = "btn btn-primary" > Kwesokunxele </inkinobho>
  3. <button type = "button" class = "btn btn-primary" > Phakathi </inkinobho>
  4. <button type = "button" class = "btn btn-primary" > Right </button>
  5. </div>

Umsakazo

Engeza data-toggle="buttons-radio"ukuze uguqule isitayela serediyo ku-btn-group.

  1. <div class = "btn-group" data-toggle = "buttons-radio" >
  2. <button type = "button" class = "btn btn-primary" > Kwesokunxele </inkinobho>
  3. <button type = "button" class = "btn btn-primary" > Phakathi </inkinobho>
  4. <button type = "button" class = "btn btn-primary" > Right </button>
  5. </div>

Ukusetshenziswa

Nika amandla izinkinobho nge-JavaScript:

  1. $ ( '.nav-tabs' ). inkinobho ()

Imakhaphu

Izibaluli zedatha ziyingxenye ye-plugin yenkinobho. Bheka ikhodi yesibonelo ngezansi ngezinhlobo ezahlukene zokumaka.

Izinketho

Lutho

Izindlela

$().inkinobho('guqula')

Iguqula isimo sohlelo. Inikeza inkinobho ukubonakala sengathi yenziwe yasebenza.

Amakhanda phezulu! Ungakwazi ukunika amandla ukuguqula okuzenzakalelayo kwenkinobho ngokusebenzisa data-toggleisibaluli.
  1. <button type = "button" class = "btn" data-toggle = "inkinobho" > </button>

$().inkinobho('iyalayisha')

Imisa isimo senkinobho ekulayisheni - inkinobho ikhubaza futhi ishintshanisa umbhalo ukuze ulayishe umbhalo. Ukulayisha umbhalo kufanele kuchazwe engxenyeni yenkinobho kusetshenziswa isibaluli sedatha data-loading-text.

  1. <button type = "button" class = "btn" data-loading-text = "ilayisha izinto..." > ... </button>
Amakhanda phezulu! I-Firefox iphikelela nesimo sokukhubaza kuwo wonke ukulayisha kwamakhasi . Isixazululo salokhu ukusetshenziswa autocomplete="off".

$().inkinobho('setha kabusha')

Isetha kabusha isimo senkinobho - ishintsha umbhalo ube umbhalo wokuqala.

$().inkinobho(uchungechunge)

Isetha kabusha isimo senkinobho - ishintshanisa umbhalo kunoma yisiphi isimo sombhalo esichazwe idatha.

  1. <button type = "button" class = "btn" data-complete-text = "kuqediwe!" > ... </inkinobho>
  2. <script>
  3. $ ( '.btn' ). inkinobho ( 'qedile' )
  4. </script>

Mayelana

Thola izitayela eziyisisekelo nosekelo oluguquguqukayo lwezingxenye ezigoqekayo njengama-accordion nokuzulazula.

* Idinga i-plugin ye-Transitions ukuthi ifakwe.

Isibonelo se-accordion

Sisebenzisa i-plugin yokugoqa, sakhe iwijethi yesitayela se-accordion elula:

Anim pariatur cliche reprehenderit, enim eiusmod high life accamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Iloli lokudla i-quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua beka inyoni kuso i-squid single-origin coffee nulla imaginenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. I-Ad vegan Exeur butcher vice lomo. I-Leggings occaecat yenza ubhiya wepulazi ukuya etafuleni, i-denim eluhlaza yobuhle be-synth nesciunt cishe awukaze uzwe ngabo i-accusamus labore i-VHS eqhubekayo.
Anim pariatur cliche reprehenderit, enim eiusmod high life accamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Iloli lokudla i-quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua beka inyoni kuso i-squid single-origin coffee nulla imaginenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. I-Ad vegan Exeur butcher vice lomo. I-Leggings occaecat yenza ubhiya wepulazi ukuya etafuleni, i-denim eluhlaza yobuhle be-synth nesciunt cishe awukaze uzwe ngabo i-accusamus labore i-VHS eqhubekayo.
Anim pariatur cliche reprehenderit, enim eiusmod high life accamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Iloli lokudla i-quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua beka inyoni kuso i-squid single-origin coffee nulla imaginenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. I-Ad vegan Exeur butcher vice lomo. I-Leggings occaecat yenza ubhiya wepulazi ukuya etafuleni, i-denim eluhlaza yobuhle be-synth nesciunt cishe awukaze uzwe ngabo i-accusamus labore i-VHS eqhubekayo.
  1. <div class = "i-accordion" id = "i-accordion2" >
  2. <div class = "iqembu le-accordion" >
  3. <div class = "isihloko se-accordion" >
  4. <a class = "accordion-toggle" data-toggle = "collapse" data-parent = "#accordion2" href = "#collapseOne" >
  5. Into Yeqembu Egoqekayo #1
  6. </a>
  7. </div>
  8. <div id = "collapseOne" class = "i-accordion-body collapse" >
  9. <div class = "i-accordion-inner" >
  10. Anim pariatur cliche...
  11. </div>
  12. </div>
  13. </div>
  14. <div class = "iqembu le-accordion" >
  15. <div class = "isihloko se-accordion" >
  16. <a class = "accordion-toggle" data-toggle = "collapse" data-parent = "#accordion2" href = "#collapseTwo" >
  17. Into Yeqembu Egoqekayo #2
  18. </a>
  19. </div>
  20. <div id = "collapseTwo" class = "i-accordion-body collapse" >
  21. <div class = "i-accordion-inner" >
  22. Anim pariatur cliche...
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. ...

Ungasebenzisa futhi i-plugin ngaphandle kwemakhaphu ye-accordion. Yenza inkinobho iguqule ukunwetshwa nokugoqa kwenye i-elementi.

  1. <button type = "button" class = "btn btn-danger" data-toggle = "collapse" data-target = "#demo" >
  2. elula egoqekayo
  3. </inkinobho>
  4.  
  5. <div id = "demo" class = "goqa phakathi" > </div>

Ukusetshenziswa

Ngezibaluli zedatha

Vele ungeze data-toggle="collapse"futhi u-a data-targetku-elementi ukuze unikeze ngokuzenzakalelayo ukulawula kwento egoqekayo. Isibaluli data-targetsamukela isikhethi se-css ongafaka kuso ukugoqa. Qiniseka ukuthi ungeza ikilasi collapseku-elementi egoqekayo. Uma ungathanda ukuthi ivuleke ngokuzenzakalelayo, engeza iklasi elengeziwe in.

Ukuze ungeze ukuphathwa kweqembu okufana ne-accordion kusilawuli esigoqekayo, engeza isibaluli sedatha data-parent="#selector". Bheka idemo ukuze ubone lokhu kusebenza.

Nge-JavaScript

Nika amandla ngokwenza nge:

  1. $ ( ".goqa" ). bhidliza ()

Izinketho

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 amanga Uma isikhethi khona-ke zonke izici ezigoqekayo ngaphansi komzali othile zizovalwa lapho le nto egoqekayo iboniswa. (okufana nokuziphatha kwe-accordion yendabuko)
guqula boolean iqiniso Iguqula into egoqekayo ekunxuseni

Izindlela

.goqa(izinketho)

Yenza okuqukethwe kwakho kusebenze njengento egoqekayo. Yamukela izinketho ozikhethela object.

  1. $ ( '#myCollapsible' ). bhidlika ({
  2. guqula : amanga
  3. })

.goqa('guqula')

Iguqula into egoqekayo ukuze iboniswe noma ifihlwe.

.goqa('show')

Ibonisa into egoqekayo.

.goqa('fihla')

Ifihla into egoqekayo.

Imicimbi

Ikilasi lokugoqa le-Bootstrap lidalula imicimbi embalwa ukuze ixhumeke ekusebenzeni kokugoqa.

Umcimbi Incazelo
umbukiso Lo mcimbi uvutha ngokushesha lapho showindlela yesibonelo ibizwa.
kubonisiwe Lo mcimbi uxoshwa lapho isici sokugoqa senziwe sabonakala kumsebenzisi (sizolinda ukuthi izinguquko ze-css ziqedele).
fihla Lo mcimbi uxoshwa ngokushesha lapho hideindlela isibiziwe.
kufihliwe Lo mcimbi uxoshwa lapho isici sokugoqa sifihliwe kumsebenzisi (sizolinda ukuthi izinguquko ze-css ziqedele).
  1. $ ( '#myCollapsible' ). ku ( 'kufihliwe' , umsebenzi () {
  2. // enza into…
  3. })

Isibonelo

I-plugin eyisisekelo, enwetshwe kalula yokudala ngokushesha ama-typehead amahle nganoma iyiphi indlela yokufaka umbhalo.

  1. <input type = "text" data-provide = "typeahead" >

Uzofuna ukusetha autocomplete="off"ukuze uvimbele amamenyu esiphequluli azenzakalelayo ukuthi angaveli phezu kokwehla kohlobo lwe-Bootstrap.


Ukusetshenziswa

Ngezibaluli zedatha

Engeza izibaluli zedatha ukuze ubhalise i-elementi ngokusebenza kwe-typeahead njengoba kuboniswe kusibonelo esingenhla.

Nge-JavaScript

Shayela i-typeahead mathupha ngokuthi:

  1. $ ( '.typeahead' ). i-typehead ()

Izinketho

Izinketho zingadluliswa ngezibaluli zedatha noma i-JavaScript. Ukuze uthole izibaluli zedatha, faka igama lenketho kokuthi data-, njengaku data-source="".

Igama uhlobo okuzenzakalelayo incazelo
umthombo uhlu, umsebenzi [ ] Umthombo wedatha ongabuza ngawo. Kungaba uchungechunge lwezintambo noma umsebenzi. Umsebenzi uphasiswe izimpikiswano ezimbili, queryinani elisendaweni yokufaka kanye ne- processcallback. Umsebenzi ungasetshenziswa ngokuhambisanayo ngokubuyisela umthombo wedatha ngokuqondile noma ngokuhambisanayo nge- processagumenti eyodwa ye-callback.
izinto inombolo 8 Inombolo enkulu yezinto ezoboniswa kokwehliswayo.
minLength inombolo 1 Ubude bezinhlamvu obuncane obudingekayo ngaphambi kokucupha iziphakamiso zokuqedela ngokuzenzakalela
umenzi umsebenzi icala alizwani Indlela esetshenziswa ukunquma ukuthi umbuzo ufana nento ethile. Yamukela i-agumenti eyodwa, itemokuzovivinywa ngayo umbuzo. Finyelela embuzweni wamanje nge- this.query. Buyisa i-boolean trueuma umbuzo ufana.
umhleli umsebenzi ukufana ncamashi,
ukuzwela
kwecala, akuzwakali
Indlela esetshenzisiwe ukuhlunga imiphumela yokuqedela ngokuzenzakalela. Yamukela impikiswano eyodwa itemsfuthi inobubanzi besibonelo se-typeahead. Bhekisela umbuzo wamanje ngokuthi this.query.
isithuthukisi umsebenzi ibuyisela into ekhethiwe Indlela esetshenzisiwe ukubuyisela into ekhethiwe. Yamukela impikiswano eyodwa, itemfuthi inobubanzi besibonelo se-typeahead.
i-highlighter umsebenzi igqamisa konke okufanayo okuzenzakalelayo Indlela esetshenzisiwe ukugqamisa imiphumela yokuqedela ngokuzenzakalela. Yamukela impikiswano eyodwa itemfuthi inobubanzi besibonelo se-typeahead. Kufanele ibuyise i-html.

Izindlela

.typeahead(izinketho)

Iqalisa okokufaka nge-typeahead.

Isibonelo

Ukuzulazula okungaphansi kwesokunxele kuyidemo ebukhoma ye-plugin ye-affix.


Ukusetshenziswa

Ngezibaluli zedatha

Ukwengeza kalula ukuziphatha kokunamathisela kunoma iyiphi i-elementi, vele ungeze data-spy="affix"ku-elementi ofuna ukuyihlola. Bese usebenzisa ama-offsets ukuchaza ukuthi ushintsha nini ukuphina kwe-elementi uvule futhi ukuvale.

  1. <div data-spy = "affix" data-offset-top = "200" > ... </div>
Amakhanda phezulu! Kufanele uphathe indawo yento ephiniwe kanye nokuziphatha komzali wayo oseduze. Isikhundla silawulwa ngu affix, affix-top, kanye affix-bottom. Khumbula ukuhlola umzali okungenzeka ukuthi ugoqe lapho isinamathiselo singena njengoba sikhipha okuqukethwe ekuhambeni okuvamile kwekhasi.

Nge-JavaScript

Shayela i-plugin ye-affix nge-JavaScript:

  1. $ ( '#navbar' ). namathisela ()

Izinketho

Izinketho zingadluliswa ngezibaluli zedatha noma i-JavaScript. Ukuze uthole izibaluli zedatha, faka igama lenketho kokuthi data-, njengaku data-offset-top="200".

Igama uhlobo okuzenzakalelayo incazelo
offset inombolo | umsebenzi | into 10 Amaphikseli okufanele uwasuse esikrinini uma ubala indawo yokuskrola. Uma inombolo eyodwa inikezwa, i-offset izosetshenziswa kuzo zombili izikhombisi-ndlela eziphezulu nesobunxele. Ukuze ulalele isiqondiso esisodwa, noma ama-offset amaningi ahlukile, vele unikeze into offset: { x: 10 }. Sebenzisa umsebenzi uma udinga ukuhlinzeka ngokushintshashintshayo (okuwusizo kweminye imiklamo esabelayo).