JavaScript

Nqa Bootstrap cov khoom rau lub neej-tam sim no nrog 13 kev cai jQuery plugins.

Tus kheej los yog muab tso ua ke

Plugins tuaj yeem suav nrog tus kheej (txawm tias qee qhov yuav tsum muaj kev vam khom), lossis tag nrho ib zaug. Ob leeg bootstrap.js thiab bootstrap.min.js muaj tag nrho cov plugins hauv ib cov ntaub ntawv.

Cov ntaub ntawv cwj pwm

Koj tuaj yeem siv tag nrho Bootstrap plugins nkaus xwb los ntawm markup API yam tsis tau sau ib kab ntawm JavaScript. Qhov no yog Bootstrap thawj chav kawm API thiab yuav tsum yog koj thawj qhov kev txiav txim siab thaum siv lub plugin.

Uas tau hais tias, hauv qee qhov xwm txheej nws yuav tsim nyog los tua qhov kev ua haujlwm no. Yog li ntawd, peb kuj muab lub peev xwm los lov tes taw cov ntaub ntawv attribute API los ntawm unbinding tag nrho cov xwm txheej ntawm lub cev namespaced nrog 'data-api''. Qhov no zoo li no:

  1. $ ( 'lub cev' ). tawm ( '.data-api' )

Xwb, txhawm rau tsom ib lub plugin tshwj xeeb, tsuas yog suav nrog lub plugin lub npe ua lub npe chaw nrog rau cov ntaub ntawv-api namespace zoo li no:

  1. $ ( 'lub cev' ). tawm ( '.alert.data-api' )

Programmatic API

Peb kuj ntseeg tias koj yuav tsum tuaj yeem siv tag nrho Bootstrap plugins nkaus xwb los ntawm JavaScript API. Tag nrho cov pej xeem APIs yog ib leeg, chainable txoj kev, thiab xa rov qab cov sau ua raws li.

  1. $ ( ".btn.danger" ). khawm ( "toggle" ). addClass ( "fat" )

Txhua txoj hauv kev yuav tsum lees txais qhov kev xaiv xaiv khoom, ib txoj hlua uas tsom rau ib txoj hauv kev, lossis tsis muaj dab tsi (uas pib lub plugin nrog tus cwj pwm tsis zoo):

  1. $ ( "#myModal" ). modal () // pib nrog defaults
  2. $ ( "#myModal" ). modal ({ keyboard : cuav }) // pib nrog tsis muaj keyboard
  3. $ ( "#myModal" ). modal ( 'show' ) // pib thiab invokes qhia tam sim

Txhua lub plugin kuj nthuav tawm nws cov neeg tsim khoom nyoos ntawm 'Constructor' cov cuab yeej: $.fn.popover.Constructor. Yog tias koj xav tau ib qho plugin tshwj xeeb, muab nws ncaj qha los ntawm lub caij: $('[rel=popover]').data('popover').

Tsis muaj teeb meem

Qee zaum nws yog qhov tsim nyog los siv Bootstrap plugins nrog rau lwm qhov UI lub luag haujlwm. Hauv cov xwm txheej no, kev sib tsoo ntawm lub npe chaw tuaj yeem tshwm sim qee zaus. Yog tias qhov no tshwm sim, koj tuaj yeem hu .noConflictrau lub plugin koj xav rov qab tus nqi ntawm.

  1. var bootstrapButton = $ . fn kev . khawm . noConflict () // xa $.fn.button rau yav tas los tus nqi
  2. $ . fn kev . bootstrapBtn = bootstrapButton // muab $().bootstrapBtn lub bootstrap functionality

Cov xwm txheej

Bootstrap muab cov xwm txheej kev cai rau feem ntau plugin qhov tshwj xeeb ua. Feem ntau, cov no tuaj nyob rau hauv daim ntawv infinitive thiab yav dhau los koom nrog - qhov twg qhov infinitive (ex. show) tshwm sim thaum pib ntawm ib qho kev tshwm sim, thiab nws daim ntawv koom nrog yav dhau los (ex. shown) yog tshwm sim ntawm qhov ua tiav ntawm qhov kev txiav txim.

Tag nrho cov xwm txheej infinitive muab kev tiv thaivDefault functionality. Qhov no muab lub peev xwm los nres qhov kev txiav txim ua ntej nws pib.

  1. $ ( '#myModal' ). ntawm ( 'show' , function ( e ) {
  2. yog tias (! data ) rov e . PreventDefault () // nres modal los ntawm kev qhia
  3. })

Hais txog kev hloov

Rau kev hloov pauv yooj yim, suav nrog bootstrap-transition.js ib zaug nrog rau lwm cov ntaub ntawv JS. Yog tias koj siv cov compiled (los yog minified) bootstrap.js , tsis tas yuav suav nrog qhov no - nws twb muaj lawm.

Siv cov ntaub ntawv

Qee qhov piv txwv ntawm kev hloov pauv plugin:

  • Sliding los yog fading nyob rau hauv modals
  • Fading tawm tabs
  • Fading tawm ceeb toom
  • Sliding carousel panes

Piv txwv

Modals yog streamlined, tab sis saj zawg zog, dialog prompts nrog yam tsawg kawg nkaus yuav tsum tau functionality thiab ntse defaults.

Piv txwv li

Ib tug rendered modal nrog header, lub cev, thiab txheej ntawm kev ua nyob rau hauv lub footer.

  1. <div class = "modal hide fade" >
  2. <div class = "modal-header" >
  3. <button type = "button" class = "kaw" data-dismiss = "modal" aria-hidden = "true" > × </button>
  4. <h3> Modal header </h3>
  5. </div>
  6. <div class = "modal-body" >
  7. <p> Ib lub cev zoo… </p>
  8. </div>
  9. <div class = "modal-footer" >
  10. <a href="#" class="btn"> Kaw </a> _ _ _ _ _
  11. <a href="#" class="btn btn-primary"> Txuag hloov pauv </a> _ _
  12. </div>
  13. </div>

Nyob demo

Toggle modal ntawm JavaScript los ntawm nias lub pob hauv qab no. Nws yuav swb thiab ploj mus los ntawm sab saum toj ntawm nplooj ntawv.

  1. <!-- Khawm los ua qauv qauv -->
  2. <a href="#myModal" role="button" class="btn" data-toggle = "modal"> Launch demo modal </a> _ _ _ _ _
  3.  
  4. <!-- Modal -->
  5. <div id = "myModal" class = "modal hide fade" tabindex = "-1" role = "dialog" aria-labeledby = "myModalLabel" aria-hidden = "true" >
  6. <div class = "modal-header" >
  7. <button type = "button" class = "kaw" data-dismiss = "modal" aria-hidden = "true" > × </button>
  8. <h3 id = "myModalLabel" > Modal header </h3>
  9. </div>
  10. <div class = "modal-body" >
  11. <p> Ib lub cev zoo… </p>
  12. </div>
  13. <div class = "modal-footer" >
  14. <button class = "btn" data-dismiss = "modal" aria-hidden = "true" > Kaw </button>
  15. <button class = "btn btn-primary" > Txuag hloov pauv </button>
  16. </div>
  17. </div>

Kev siv

Los ntawm cov ntaub ntawv attributes

Qhib lub modal yam tsis tau sau JavaScript. Teem data-toggle="modal"rau ntawm tus tswj lub caij, zoo li lub pob, nrog rau ib data-target="#foo"lossis href="#foo"rau lub hom phiaj ib qho kev hloov pauv.

  1. <khawm hom = "button" data-toggle = "modal" data-target = "#myModal" > Launch modal </button>

Ntawm JavaScript

Hu rau modal nrog id myModalnrog ib kab ntawm JavaScript:

  1. $ ( '#myModal' ). modal ( kev xaiv )

Kev xaiv

Cov kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript. Rau cov ntaub ntawv tus cwj pwm, ntxiv rau qhov kev xaiv npe rau data-, xws li hauv data-backdrop="".

Lub npe hom ua ntej piav qhia
keeb kwm yav dhau boolean muaj tseeb Xws li ib qho modal-backdrop element. Xwb, qhia meej staticrau ib qho backdrop uas tsis kaw lub modal ntawm nias.
keyboard boolean muaj tseeb Kaw lub modal thaum khiav qhov tseem ceeb yog nias
ua yeeb yam boolean muaj tseeb Qhia cov modal thaum pib.
nyob deb txoj kev cuav

Yog hais tias ib tug tej thaj chaw deb url yog muab, cov ntsiab lus yuav loaded ntawm jQuery txoj loadkev thiab txhaj rau hauv lub .modal-body. Yog tias koj siv cov ntaub ntawv api, koj tuaj yeem siv lub hrefcim npe los qhia qhov chaw nyob deb. Ib qho piv txwv ntawm qhov no yog qhia hauv qab no:

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

Cov txheej txheem

.modal(options)

Activates koj cov ntsiab lus raws li ib tug modal. Txais ib qho kev xaiv xaiv object.

  1. $ ( '#myModal' ). modal ({
  2. keyboard : cuav
  3. })

.modal('toggle')

Manually toggles ib modal.

  1. $ ( '#myModal' ). modal ( 'toggle' )

.modal('qhia')

Manually qhib lub modal.

  1. $ ( '#myModal' ). modal ( 'qhia' )

.modal('hide')

Manually hides ib modal.

  1. $ ( '#myModal' ). modal ( 'Hide' )

Cov xwm txheej

Bootstrap's modal class exposes ob peb txheej xwm rau hooking rau hauv modal functionality.

Kev tshwm sim Kev piav qhia
ua yeeb yam Qhov xwm txheej no tua hluav taws tam sim ntawd thaum showhu ua piv txwv.
qhia Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub modal tau ua kom pom rau tus neeg siv (yuav tos rau css kev hloov pauv kom tiav).
zais Qhov xwm txheej no raug rho tawm haujlwm tam sim ntawd thaum hidehu ua piv txwv txoj kev.
zais cia Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub modal tiav lawm muab zais los ntawm tus neeg siv (yuav tos rau css hloov mus ua kom tiav).
  1. $ ( '#myModal' ). ntawm ( 'hidden' , function () {
  2. // ua ib yam dab tsi…
  3. })

Piv txwv hauv navbar

Lub ScrollSpy plugin yog rau kev hloov kho nav lub hom phiaj raws li txoj haujlwm scroll. Scroll thaj tsam hauv qab ntawm navbar thiab saib cov chav kawm hloov pauv. Lub dropdown sub cov khoom yuav raug highlighted thiab.

@fat

Ad leggings keytar, brunch id art party dolor ua haujlwm. Pitchfork yr enim lo-fi ua ntej lawv muag tawm qui. Tumblr ua liaj ua teb-rau- rooj tsheb kauj vab txoj cai txawm li cas los xij. Ntxim hlub cardigan. Velit seitan mcsweeney's photo booth 3 hma hli irure. Cosby sweater lomo jean luv, williamsburg hoodie minim qui koj tej zaum tsis tau hnov ​​​​txog lawv thiab cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.

@mdo

Veniam marfa mustache skateboard, adipisicing fugiat velit pitchfork hwj txwv. Freegan hwj txwv aliqua cupidatat mcsweeney's vero. Cupidatat plaub loko nisi, ea helvetica nulla carles. Tattooed cosby sweater zaub mov tsheb, mcsweeney's quis non freegan vinyl. Lo-fi wes anderson +1 sartorial. Carles tsis zoo nkauj exercitation quis gentrify. Brooklyn adipisicing khoom siv tes ua npias vice keytar deserunt.

ib

Occaecat commodo aliqua delectus. Fap craft npias deserunt skateboard ea. Lomo tsheb kauj vab txoj cai adipisicing banh mi, velit ea sunt tom ntej no locavore single-origin kas fes hauv magna veniam. High life id vinyl, ncho park consequat quis aliquip banh mi pitchfork. Vero VHS yog adipisicing. Consectetur nisi DIY minim tub txib hnab. Cred ex nyob rau hauv, sustainable delectus consectetur fanny pob iphone.

ob

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 tub txib hnab marfa txawm delectus zaub mov tsheb. Sapiente synth id assumenda. Locavore sed helvetica cliche irony, thundercats tej zaum koj tsis tau hnov ​​​​txog lawv ua rau hoodie gluten-dawb lo-fi fap aliquip. Labore elit placeat ua ntej lawv muag tawm, terry richardson proident brunch nesciunt quis cosby sweater pariatur keffiyeh ut helvetica artisan. Cardigan craft npias seitan readymade velit. VHS Chambray Laboris Tempor Veniam. Anim mollit minim commodo ullamco thundercats.


Kev siv

Los ntawm cov ntaub ntawv attributes

Txhawm rau yooj yim ntxiv tus cwj pwm scrollspy rau koj qhov topbar navigation, tsuas yog ntxiv data-spy="scroll"rau lub caij koj xav kom neeg soj xyuas rau (feem ntau qhov no yuav yog lub cev) thiab data-target=".navbar"xaiv qhov twg siv nav. Koj yuav xav siv scrollspy nrog ib .navfeem.

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

Ntawm JavaScript

Hu rau scrollspy ntawm JavaScript:

  1. $ ( '#navbar' ). scrollspy ()
Tau taub hau! Navbar txuas yuav tsum muaj lub hom phiaj id daws tau. Piv txwv li, ib tug <a href="#home">home</a>yuav tsum sib haum mus rau ib yam dab tsi nyob rau hauv lub dom zoo li <div id="home"></div>.

Cov txheej txheem

.scrollspy('refresh')

Thaum siv scrollspy ua ke nrog kev ntxiv lossis tshem tawm cov ntsiab lus los ntawm DOM, koj yuav tsum hu rau txoj kev hloov tshiab zoo li:

  1. $ ( '[data-spy="scroll"]' ). txhua ( function () {
  2. var $spy = $ ( this ). scrollspy ( 'tshiab' )
  3. });

Kev xaiv

Cov kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript. Rau cov ntaub ntawv tus cwj pwm, ntxiv rau qhov kev xaiv npe rau data-, xws li hauv data-offset="".

Lub npe hom ua ntej piav qhia
offset tus lej 10 Pixels rau offset los ntawm sab saum toj thaum xam txoj hauj lwm ntawm scroll.

Cov xwm txheej

Kev tshwm sim Kev piav qhia
qhib Qhov xwm txheej no tua hluav taws thaum twg ib yam khoom tshiab tau qhib los ntawm scrollspy.

Piv txwv tabs

Ntxiv ceev, dynamic tab functionality rau kev hloov mus los ntawm panes ntawm cov ntsiab lus hauv zos, txawm tias ntawm dropdown menus.

Raw denim tej zaum koj tsis tau hnov ​​​​txog lawv cov ris tsho luv Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit neeg tua tsiaj retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, neeg tua tsiaj 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.


Kev siv

Qhib tabbable tabs ntawm JavaScript (txhua tab yuav tsum tau qhib ib tus zuj zus):

  1. $ ( '#myTab a' ). nyem ( function ( e ) {
  2. e . PreventDefault ();
  3. $ ( qhov no ). tab ( 'show' );
  4. })

Koj tuaj yeem qhib ib tus neeg tab hauv ntau txoj hauv kev:

  1. $ ( '#myTab a[href="#profile"]' ). tab ( 'show' ); // Xaiv tab los ntawm lub npe
  2. $ ( '#myTab a: ua ntej' ). tab ( 'show' ); // Xaiv thawj tab
  3. $ ( '#myTab a:last' ). tab ( 'show' ); // Xaiv lub tab kawg
  4. $ ( '#myTab li:eq(2) a' ). tab ( 'show' ); // Xaiv thib peb tab (0-indexed)

Markup

Koj tuaj yeem qhib lub tab lossis ntsiav tshuaj navigation yam tsis tau sau ib qho JavaScript los ntawm kev qhia yooj yim data-toggle="tab"lossis data-toggle="pill"ntawm lub ntsiab lus. Ntxiv cov navthiab nav-tabscov chav kawm rau lub tab ulyuav siv Bootstrap tab styling.

  1. <ul class = "nav nav-tabs" >
  2. <li><a href = "#home" data-toggle = "tab"> Tsev </a></li >
  3. <li><a href = "#profile" data-toggle = "tab"> Profile </a></li >
  4. <li><a href = "#messages" data-toggle = "tab"> Messages </a></li >
  5. <li><a href = "#settings" data-toggle = "tab"> Settings </a></li >
  6. </ul>

Cov txheej txheem

$().tab

Activates lub tab element thiab cov ntsiab lus ntim. Tab yuav tsum muaj ib data-targetlossis ib lub hrefhom phiaj rau lub thawv ntim hauv DOM.

  1. <ul class = "nav nav-tabs" id = "myTab" >
  2. <li class = "active" ><a href = "#home"> Tsev </a></li >
  3. <li><a href = "#profile"> Profile </a> </li>
  4. <li><a href = "#messages"> Messages </a> </li>
  5. <li><a href = "#settings"> Chaw </a> </li>
  6. </ul>
  7.  
  8. <div class = "tab-content" >
  9. <div class = "tab-pane active" id = "home" > ... </div>
  10. <div class = "tab-pane" id = "profile" > ... </div>
  11. <div class = "tab-pane" id = "messages" > ... </div>
  12. <div class = "tab-pane" id = "settings" > ... </div>
  13. </div>
  14.  
  15. <script>
  16. $ ( function () {
  17. $ ( '#myTab a:last' ). tab ( 'show' );
  18. })
  19. </script>

Cov xwm txheej

Kev tshwm sim Kev piav qhia
ua yeeb yam Qhov kev tshwm sim no tua hluav taws ntawm tab qhia, tab sis ua ntej tab tshiab tau tshwm sim. Siv event.targetthiab event.relatedTargettsom rau lub tab active thiab yav dhau los active tab (yog tias muaj) feem.
qhia Qhov xwm txheej no tua hluav taws ntawm tab qhia tom qab tau pom tab. Siv event.targetthiab event.relatedTargettsom rau lub tab active thiab yav dhau los active tab (yog tias muaj) feem.
  1. $ ( 'a[data-toggle="tab"]' ). on ( 'qhia' , function ( e ) {
  2. e . phiaj // activated tab
  3. e . RelatedTarget // yav dhau los tab
  4. })

Piv txwv

Kev tshoov siab los ntawm qhov zoo tshaj plaws jQuery.tipsy plugin sau los ntawm Jason Frame; Cov lus qhia yog ib qho kev hloov kho tshiab, uas tsis tso siab rau cov duab, siv CSS3 rau cov yeeb yaj kiab, thiab cov ntaub ntawv-tus cwj pwm rau cov npe hauv zos.

Rau cov laj thawj kev ua tau zoo, cov lus qhia thiab cov ntaub ntawv popover-apis yog xaiv rau hauv, txhais tau tias koj yuav tsum pib lawv tus kheej .

Hover tshaj qhov txuas hauv qab no kom pom cov lus qhia:

Tight ris tom ntej no keffiyeh tej zaum koj yuav tsis tau hnov ​​txog lawv. Diam duab lub rooj muag zaub beard raw denim letterpress vegan tub txib hnab stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-ntsis american apparel muaj terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, plaub loko mcsweeney's cleanse vegan chambray. Ib tus kws txawj ntse tiag tiag txawm li cas los xij keytar , scenester ua liaj ua teb-rau- rooj banksy Austin twitter tuav freegan cred nyoos denim ib leeg-hauv paus kas fes kis.

Plaub txoj kev

Cov lus qhia hauv pab pawg tswv yim

Thaum siv cov lus qhia thiab popovers nrog Bootstrap cov tswv yim pab pawg, koj yuav tau teeb tsa container(cov ntaub ntawv hauv qab no) kev xaiv kom tsis txhob muaj kev phiv tsis zoo.


Kev siv

Tig lub cuab yeej ntawm JavaScript:

  1. $ ( '#example' ). tooltip ( Options )

Kev xaiv

Cov kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript. Rau cov ntaub ntawv tus cwj pwm, ntxiv rau qhov kev xaiv npe rau data-, xws li hauv data-animation="".

Lub npe hom ua ntej piav qhia
animation boolean muaj tseeb siv css ploj mus rau cov lus qhia
html boolean cuav Ntxig html rau hauv cov lus qhia. Yog tias tsis tseeb, jquery txoj textkev yuav raug siv los ntxig cov ntsiab lus rau hauv dom. Siv cov ntawv nyeem yog tias koj txhawj xeeb txog XSS tawm tsam.
tso chaw hlua | muaj nuj nqi 'sab saum toj' yuav ua li cas rau position lub tooltip - sab saum toj | hauv qab | sab laug | txoj cai
xaiv txoj hlua cuav Yog hais tias muaj ib tug selector, tooltip cov khoom yuav raug delegated rau lub hom phiaj teev.
lub npe hlua | muaj nuj nqi '' default title value yog 'title' tag tsis nyob
ua rau txoj hlua 'hover focus' yuav ua li cas tooltip yog triggered - nyem | hover | tsom | phau ntawv. Nco ntsoov tias koj kis tus kab mob sib kis, qhov chaw sib cais, hom kab mob.
ncua tus lej | khoom 0

ncua kev qhia thiab zais cov lus qhia (ms) - tsis siv rau phau ntawv txhais hom

Yog tias muaj tus lej nkag, ncua sijhawm yog siv rau ob qho tib si zais / qhia

Object structure yog:delay: { show: 500, hide: 100 }

thawv hlua | cuav cuav

Appends lub tooltip rau ib lub caij tshwj xeebcontainer: 'body'

Tau taub hau! Cov kev xaiv rau tus kheej cov lus qhia tuaj yeem hloov pauv tau los ntawm kev siv cov ntaub ntawv cwj pwm.

Markup

  1. <a href = "#" data-toggle = "tooltip" title = "thawj tooltip" > hover over me </a>

Cov txheej txheem

$().tooltip(options)

Txuas tus tooltip handler rau ib qho khoom sau.

.tooltip('show')

Qhia ib lub ntsiab lus qhia.

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

.tooltip('hide')

Hide ib lub ntsiab lus qhia.

  1. $ ( '#element' ). tooltip ( 'Hide' )

.tooltip('toggle')

Toggles ib lub ntsiab lus qhia.

  1. $ ( '#element' ). tooltip ( 'toggle' )

.tooltip('ua kom puas')

Nias thiab rhuav tshem cov ntsiab lus ntawm cov cuab yeej.

  1. $ ( '#element' ). tooltip ( 'ua kom puas' )

Piv txwv

Ntxiv me me ntawm cov ntsiab lus, zoo li cov hauv iPad, rau txhua lub hauv paus rau cov ntaub ntawv thib ob hauv tsev. Hover tshaj lub khawm kom ua rau lub popover. Yuav tsum muaj Tooltip kom suav nrog.

Static popover

Plaub txoj kev xaiv muaj: sab saum toj, sab xis, hauv qab, thiab sab laug dlhos.

Popover saum

Sed posuere consectetur yog nyob rau hauv lobortis. Aenean eu leo ​​quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Popover txoj cai

Sed posuere consectetur yog nyob rau hauv lobortis. Aenean eu leo ​​quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Popover hauv qab

Sed posuere consectetur yog nyob rau hauv lobortis. Aenean eu leo ​​quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Popover sab laug

Sed posuere consectetur yog nyob rau hauv lobortis. Aenean eu leo ​​quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Tsis muaj qhov cim qhia tias popovers yog tsim los ntawm JavaScript thiab cov ntsiab lus hauv tus datacwj pwm.

Nyob demo

Plaub txoj kev


Kev siv

Qhib popovers ntawm JavaScript:

  1. $ ( '#example' ). popover ( kev xaiv )

Kev xaiv

Cov kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript. Rau cov ntaub ntawv tus cwj pwm, ntxiv rau qhov kev xaiv npe rau data-, xws li hauv data-animation="".

Lub npe hom ua ntej piav qhia
animation boolean muaj tseeb siv css ploj mus rau cov lus qhia
html boolean cuav Ntxig html rau hauv popover. Yog tias tsis tseeb, jquery txoj textkev yuav raug siv los ntxig cov ntsiab lus rau hauv dom. Siv cov ntawv nyeem yog tias koj txhawj xeeb txog XSS tawm tsam.
tso chaw hlua | muaj nuj nqi 'txoj cai' yuav ua li cas tso lub popover - saum | hauv qab | sab laug | txoj cai
xaiv txoj hlua cuav Yog hais tias muaj ib tug selector, tooltip cov khoom yuav raug delegated rau lub hom phiaj
ua rau txoj hlua 'nias' yuav ua li cas popover yog triggered - nyem | hover | tsom | phau ntawv
lub npe hlua | muaj nuj nqi '' default title value yog 'title' attribute tsis nyob
cov ntsiab lus hlua | muaj nuj nqi '' default ntsiab lus tus nqi yog 'cov ntaub ntawv-cov ntsiab lus' tus cwj pwm tsis nyob
ncua tus lej | khoom 0

ncua kev qhia thiab zais qhov popover (ms) - tsis siv rau phau ntawv txhais hom

Yog tias muaj tus lej nkag, ncua sijhawm yog siv rau ob qho tib si zais / qhia

Object structure yog:delay: { show: 500, hide: 100 }

thawv hlua | cuav cuav

Appends lub popover rau ib yam khoomcontainer: 'body'

Tau taub hau! Cov kev xaiv rau ib tus neeg popovers tuaj yeem hloov tau los ntawm kev siv cov ntaub ntawv cwj pwm.

Markup

Rau kev ua tau zoo vim li cas, Tooltip thiab Popover cov ntaub ntawv-apis yog xaiv rau hauv. Yog tias koj xav siv lawv tsuas yog qhia qhov kev xaiv xaiv.

Cov txheej txheem

$().popover(options)

Initializes popovers rau ib qho khoom sau.

.popover('show')

Tshaj tawm cov ntsiab lus popover.

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

.popover('hide')

Hide cov ntsiab lus popover.

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

.popover('toggle')

Toggles lub ntsiab lus popover.

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

.popover('ua kom puas')

Nias thiab rhuav tshem lub ntsiab lus popover.

  1. $ ( '#element' ). popover ( 'ua kom puas' )

Piv txwv ceeb toom

Ntxiv tso tawm haujlwm rau tag nrho cov lus ceeb toom nrog cov plugin no.

Dawb huv guacamole! Qhov zoo tshaj plaws xyuas koj tus kheej, koj tsis zoo heev.

Aw snap! Koj tau qhov yuam kev!

Hloov qhov no thiab qhov ntawd thiab sim dua. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus zaum amet fermentum.

Ua qhov no Los yog ua qhov no


Kev siv

Pab kom tshem tawm kev ceeb toom ntawm JavaScript:

  1. $ ( ".alert" ). ceeb toom ( )

Markup

Tsuas yog ntxiv data-dismiss="alert"rau koj lub khawm kaw kom tau txais kev ceeb toom kaw ua haujlwm.

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

Cov txheej txheem

$().alert()

Wraps tag nrho cov lus ceeb toom nrog ze functionality. Txhawm rau kom koj cov lus ceeb toom tawm thaum kaw, xyuas kom lawv muaj cov chav kawm .fadethiab .incov chav kawm twb tau thov rau lawv.

.alert('kaw')

Kaw ceeb toom.

  1. $ ( ".alert" ). ceeb toom ( 'kaw' )

Cov xwm txheej

Bootstrap's alert class exposes ob peb txheej xwm rau hooking rau hauv alert functionality.

Kev tshwm sim Kev piav qhia
kaw Qhov xwm txheej no tua hluav taws tam sim ntawd thaum closehu ua piv txwv.
kaw Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub ceeb toom tau raug kaw (yuav tos rau css kev hloov pauv kom tiav).
  1. $ ( '#my-alert' ). khi ( 'kaw' , ua haujlwm () {
  2. // ua ib yam dab tsi…
  3. })

Piv txwv siv

Ua ntau nrog cov nyees khawm. Tswj khawm hais los yog tsim pab pawg ntawm cov nyees khawm rau ntau yam xws li toolbars.

Xeev

Ntxiv data-loading-text="Loading..."rau siv lub xeev loading ntawm ib lub pob.

  1. <button type = "button" class = "btn btn-primary" data-loading-text = "Loading..." > Chaw thau khoom xeev </button>

Ib leeg toggle

Ntxiv data-toggle="button"rau qhib toggling ntawm ib lub pob.

  1. <button type = "button" class = "btn btn-primary" data-toggle = "button" > Ib Leeg Toggle </button>

Checkbox

Ntxiv data-toggle="buttons-checkbox"rau checkbox style toggling ntawm btn-group.

  1. <div class = "btn-group" data-toggle = "buttons-checkbox" >
  2. <button type = "button" class = "btn btn-primary" > laug </button>
  3. <button type = "button" class = "btn btn-primary" > nruab nrab </button>
  4. <button type = "button" class = "btn btn-primary" > Txoj Cai </button>
  5. </div>

Xov tooj cua

Ntxiv data-toggle="buttons-radio"rau xov tooj cua style toggling ntawm btn-group.

  1. <div class = "btn-group" data-toggle = "buttons-radio" >
  2. <button type = "button" class = "btn btn-primary" > laug </button>
  3. <button type = "button" class = "btn btn-primary" > nruab nrab </button>
  4. <button type = "button" class = "btn btn-primary" > Txoj Cai </button>
  5. </div>

Kev siv

Qhib cov nyees khawm ntawm JavaScript:

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

Markup

Cov ntaub ntawv tus cwj pwm yog ib qho tseem ceeb rau lub khawm plugin. Txheeb xyuas qhov piv txwv hauv qab no rau ntau hom cim.

Kev xaiv

Tsis muaj

Cov txheej txheem

$().button('toggle')

Toggles thawb lub xeev. Muab lub pob kom pom tias nws tau qhib.

Tau taub hau! Koj tuaj yeem ua kom nws pib toggling ntawm lub pob los ntawm kev siv tus data-togglecwj pwm.
  1. <button type = "button" class = "btn" data-toggle = "button" > </button>

$().button('loading')

Teem khawm lub xeev rau kev thauj khoom - disables khawm thiab swaps ntawv rau loading ntawv. Loading ntawv yuav tsum tau txhais nyob rau hauv lub khawm caij siv cov ntaub ntawv attribute data-loading-text.

  1. <button type = "button" class = "btn" data-loading-text = "loading khoom..." > ... </button>
Tau taub hau! Firefox txuas ntxiv rau lub xeev neeg xiam oob khab hla nplooj ntawv . Ib qho kev daws teeb meem rau qhov no yog siv autocomplete="off".

$().button('reset')

Resets khawm lub xeev - swaps ntawv rau cov ntawv qub.

$().button(string)

Resets khawm lub xeev - swaps cov ntawv mus rau cov ntaub ntawv teev cov ntawv hauv xeev.

  1. <button type = "button" class = "btn" data-complete-text = "finished!" > ... </button>
  2. <script>
  3. $ ( '.btn' ). khawm ( 'ua tiav' )
  4. </script>

Txog

Tau txais cov qauv tsim thiab hloov pauv hloov pauv rau cov khoom sib tsoo zoo li accordions thiab navigation.

* Yuav tsum muaj Transitions plugin kom suav nrog.

Piv txwv accordion

Siv lub cev qhuav dej, peb tsim ib qho yooj yim accordion style widget:

Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 hma hli official aute, non cupidatat skateboard dolor brunch. Khoom noj khoom haus tsheb quinoa nesciunt lab eiusmod. Brunch 3 hma hli tempor, sunt aliqua muab ib tug noog rau nws squid ib leeg-hauv paus kas fes nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer laboure wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur neeg tua tsiaj vice lomo. Leggings occaecat khoom siv tes ua npias ua liaj ua teb-rau- rooj, nyoos denim aesthetic synth nesciunt tej zaum koj tsis tau hnov ​​​​txog lawv accusamus ua haujlwm ruaj khov VHS.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 hma hli official aute, non cupidatat skateboard dolor brunch. Khoom noj khoom haus tsheb quinoa nesciunt lab eiusmod. Brunch 3 hma hli tempor, sunt aliqua muab ib tug noog rau nws squid ib leeg-hauv paus kas fes nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer laboure wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur neeg tua tsiaj vice lomo. Leggings occaecat khoom siv tes ua npias ua liaj ua teb-rau- rooj, nyoos denim aesthetic synth nesciunt tej zaum koj tsis tau hnov ​​​​txog lawv accusamus ua haujlwm ruaj khov VHS.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 hma hli official aute, non cupidatat skateboard dolor brunch. Khoom noj khoom haus tsheb quinoa nesciunt lab eiusmod. Brunch 3 hma hli tempor, sunt aliqua muab ib tug noog rau nws squid ib leeg-hauv paus kas fes nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer laboure wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur neeg tua tsiaj vice lomo. Leggings occaecat khoom siv tes ua npias ua liaj ua teb-rau- rooj, nyoos denim aesthetic synth nesciunt tej zaum koj tsis tau hnov ​​​​txog lawv accusamus ua haujlwm ruaj khov VHS.
  1. <div class = "accordion" id = "accordion2" >
  2. <div class = "accordion-group" >
  3. <div class = "accordion-heading" >
  4. <a class = "accordion-toggle" data-toggle = "collapse" data-parent = "#accordion2" href = "#collapseOne" >
  5. Collapsible Group Yam #1
  6. </a>
  7. </div>
  8. <div id = "collapseOne" class = "accordion-lub cev poob rau hauv" >
  9. <div class = "accordion-inner" >
  10. Dab neeg poj ntxoog...
  11. </div>
  12. </div>
  13. </div>
  14. <div class = "accordion-group" >
  15. <div class = "accordion-heading" >
  16. <a class = "accordion-toggle" data-toggle = "collapse" data-parent = "#accordion2" href = "#collapseTwo" >
  17. Collapsible Group Yam #2
  18. </a>
  19. </div>
  20. <div id = "collapseTwo" class = "accordion-lub cev ploj" >
  21. <div class = "accordion-inner" >
  22. Dab neeg poj ntxoog...
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. ...

Koj tuaj yeem siv lub plugin yam tsis muaj accordion markup. Ua ib lub pob toggle lub expanding thiab collapsing ntawm lwm lub caij.

  1. <khawm hom = "button" class = "btn btn-danger" data-toggle = "collapse" data-target = "#demo" >
  2. yooj yim collapsible
  3. </button>
  4.  
  5. <div id = "demo" class = "collapse in" > </div>

Kev siv

Los ntawm cov ntaub ntawv attributes

Tsuas yog ntxiv data-toggle="collapse"thiab ib qho data-targetrau lub caij kom tau txais kev tswj hwm ntawm lub caij collapsible. Tus data-targetcwj pwm lees txais css xaiv los siv lub cev qhuav dej rau. Nco ntsoov ntxiv cov chav kawm collapserau lub caij collapsible. Yog tias koj xav kom nws qhib lub neej ntawd, ntxiv cov chav kawm ntxiv in.

Txhawm rau ntxiv accordion-zoo li pawg tswj hwm rau kev tswj hwm, ntxiv cov ntaub ntawv tus cwj pwm data-parent="#selector". Xa mus rau qhov demo kom pom qhov no hauv kev nqis tes ua.

Ntawm JavaScript

Qhib manually nrog:

  1. $ ( ".collapse" ). poob ( )

Kev xaiv

Cov kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript. Rau cov ntaub ntawv tus cwj pwm, ntxiv rau qhov kev xaiv npe rau data-, xws li hauv data-parent="".

Lub npe hom ua ntej piav qhia
niam txiv xaiv cuav Yog tias selector ces tag nrho cov ntsiab lus collapsible nyob rau hauv cov niam txiv uas tau teev tseg yuav raug kaw thaum cov khoom no collapsible tshwm sim. (zoo ib yam li kev coj cwj pwm accordion)
toggle boolean muaj tseeb Toggles lub caij collapsible ntawm invocation

Cov txheej txheem

.collapse(options)

Activates koj cov ntsiab lus raws li lub ntsiab collapsible. Txais ib qho kev xaiv xaiv object.

  1. $ ( '#myCollapsible' ). ploj ({
  2. toggle : cuav
  3. })

.collapse('toggle')

Toggles lub caij collapsible kom pom los yog zais.

.collapse('show')

Qhia ib lub caij collapsible.

.collapse('hide')

Hide ib lub caij collapsible.

Cov xwm txheej

Bootstrap's collapse class exposes ob peb txheej xwm rau hooking mus rau hauv vau functionality.

Kev tshwm sim Kev piav qhia
ua yeeb yam Qhov xwm txheej no tua hluav taws tam sim ntawd thaum showhu ua piv txwv.
qhia Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub caij sib tsoo tau ua kom pom rau tus neeg siv (yuav tos rau css kev hloov pauv kom tiav).
zais Qhov kev tshwm sim no raug rho tawm haujlwm tam sim ntawd thaum hidehu ua txoj kev.
zais cia Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub caij sib tsoo tau muab zais los ntawm tus neeg siv (yuav tos rau css kev hloov pauv kom tiav).
  1. $ ( '#myCollapsible' ). ntawm ( 'hidden' , function () {
  2. // ua ib yam dab tsi…
  3. })

Piv txwv

Ib qho yooj yim, yooj yim txuas ntxiv plugin rau sai sai tsim elegant typeaheads nrog rau cov ntawv sau ntawv nkag.

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

Koj yuav xav teem caij autocomplete="off"los tiv thaiv cov ntawv qhia zaub mov tsis zoo los ntawm qhov tshwm sim ntawm Bootstrap typeahead dropdown.


Kev siv

Los ntawm cov ntaub ntawv attributes

Ntxiv cov ntaub ntawv tus cwj pwm los sau npe ib lub caij nrog typeahead functionality raws li qhia hauv qhov piv txwv saum toj no.

Ntawm JavaScript

Hu rau typeahead manually nrog:

  1. $ ( '.typeahead' ). ntaus ntawv ( )

Kev xaiv

Cov kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript. Rau cov ntaub ntawv tus cwj pwm, ntxiv rau qhov kev xaiv npe rau data-, xws li hauv data-source="".

Lub npe hom ua ntej piav qhia
qhov chaw array, ua haujlwm [] Cov ntaub ntawv los nug tawm tsam. Tej zaum yuav yog ib qho array ntawm cov hlua los yog kev ua haujlwm. Qhov kev ua haujlwm tau dhau ob qhov kev sib cav, tus querynqi hauv qhov chaw nkag thiab processhu rov qab. Kev ua haujlwm yuav raug siv synchronously los ntawm kev xa rov qab cov ntaub ntawv ncaj qha lossis asynchronously ntawm kev processhu rov qab qhov kev sib cav.
cov khoom tus lej 8 Tus naj npawb max ntawm cov khoom los tso saib hauv qhov poob.
minLength tus lej 1 Yam tsawg kawg nkaus qhov ntev uas yuav tsum tau ua ua ntej ua kom tiav cov lus qhia autocomplete
tus sib tw muaj nuj nqi cas insensitive Txoj kev siv los txiav txim siab seb qhov lus nug puas phim ib yam khoom. Txais ib qho kev sib cav, qhov itemtawm tsam uas yuav sim cov lus nug. Nkag mus rau cov lus nug tam sim no nrog this.query. Rov qab ib qho boolean trueyog tias cov lus nug yog qhov sib tw.
tus txheej txheem muaj nuj nqi qhov tseeb match,
case sensitive,
case insensitive
Txoj kev siv los txheeb cov txiaj ntsig autocomplete. Txais ib qho kev sib cav itemsthiab muaj lub peev xwm ntawm qhov piv txwv typeahead. Siv cov lus nug tam sim no nrog this.query.
hloov tshiab muaj nuj nqi rov qab cov khoom xaiv Txoj kev siv los xa cov khoom xaiv. Txais ib qho kev sib cav, itemthiab muaj lub peev xwm ntawm qhov piv txwv typeahead.
highlighter muaj nuj nqi highlights tag nrho cov default match Txoj kev siv los qhia txog cov txiaj ntsig autocomplete. Txais ib qho kev sib cav itemthiab muaj lub peev xwm ntawm qhov piv txwv typeahead. Yuav tsum rov html.

Cov txheej txheem

.typeahead(options)

Initializes ib tug input nrog ib tug typeahead.

Piv txwv

Lub subnavigation nyob rau sab laug yog ib tug nyob demo ntawm affix plugin.


Kev siv

Los ntawm cov ntaub ntawv attributes

Txhawm rau yooj yim ntxiv affix cwj pwm rau txhua lub caij, tsuas yog ntxiv data-spy="affix"rau lub caij koj xav soj ntsuam. Tom qab ntawd siv offsets los txhais thaum twg los hloov lub pinning ntawm ib lub caij rau thiab tawm.

  1. <div data-spy = "affix" data-offset-top = "200" > ... </div>
Tau taub hau! Koj yuav tsum tswj hwm txoj haujlwm ntawm tus pinned keeb thiab tus cwj pwm ntawm nws niam txiv tam sim ntawd. Txoj hauj lwm yog tswj los ntawm affix, affix-top, thiab affix-bottom. Nco ntsoov xyuas cov niam txiv uas muaj feem cuam tshuam thaum lub affix kicks nyob rau hauv raws li nws yog tshem tawm cov ntsiab lus los ntawm qhov ib txwm ntws ntawm nplooj ntawv.

Ntawm JavaScript

Hu rau affix plugin ntawm JavaScript:

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

Kev xaiv

Cov kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript. Rau cov ntaub ntawv tus cwj pwm, ntxiv rau qhov kev xaiv npe rau data-, xws li hauv data-offset-top="200".

Lub npe hom ua ntej piav qhia
offset tus lej | muaj nuj nqi | khoom 10 Pixels rau offset los ntawm kev tshuaj ntsuam thaum xam txoj hauj lwm ntawm scroll. Yog tias muab ib tus lej, qhov offset yuav raug siv rau ob qho tib si sab saum toj thiab sab laug. Txhawm rau mloog rau ib qho kev taw qhia, lossis ntau qhov txawv txav, tsuas yog muab ib qho khoom offset: { x: 10 }. Siv ib qho kev ua haujlwm thaum koj xav tau dynamically muab qhov offset (pab tau rau qee qhov qauv tsim).