JavaScript
Nqa Bootstrap cov khoom rau lub neej nrog ntau tshaj li kaum kev cai jQuery plugins. Yooj yim suav nrog lawv tag nrho, lossis ib qho los ntawm ib qho.
Nqa Bootstrap cov khoom rau lub neej nrog ntau tshaj li kaum kev cai jQuery plugins. Yooj yim suav nrog lawv tag nrho, lossis ib qho los ntawm ib qho.
Plugins tuaj yeem suav nrog tus kheej (siv Bootstrap tus kheej *.js
cov ntaub ntawv), lossis tag nrho ib zaug (siv bootstrap.js
lossis cov minified bootstrap.min.js
).
Ob leeg bootstrap.js
thiab bootstrap.min.js
muaj tag nrho cov plugins hauv ib cov ntaub ntawv. suav ib leeg xwb.
Qee cov plugins thiab CSS cov khoom nyob ntawm lwm cov plugins. Yog tias koj suav nrog plugins ib tus zuj zus, nco ntsoov xyuas cov kev vam meej hauv cov ntaub ntawv. Tsis tas li ntawd nco ntsoov tias tag nrho cov plugins nyob ntawm jQuery (qhov no txhais tau tias jQuery yuav tsum tau suav nrog ua ntej cov ntaub ntawv plugin). Nrog pebbower.json
saib seb jQuery versions twg tau txais kev txhawb nqa.
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's first-class 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 txheej xwm ntawm cov ntaub ntawv namespaced nrog data-api
. Qhov no zoo li no:
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:
Tsis txhob siv cov ntaub ntawv tus cwj pwm los ntawm ntau lub plugins ntawm tib lub caij. Piv txwv li, ib lub pob tsis tuaj yeem muaj cov lus qhia thiab toggle modal. Yuav kom ua tiav qhov no, siv cov khoom qhwv.
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.
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):
Txhua lub plugin kuj nthuav tawm nws cov neeg tsim khoom nyoos ntawm cov Constructor
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')
.
Koj tuaj yeem hloov qhov chaw pib rau lub plugin los ntawm kev hloov kho lub plugin cov Constructor.DEFAULTS
khoom:
Qee lub sij hawm 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 .noConflict
rau lub plugin koj xav rov qab tus nqi ntawm.
Bootstrap muab cov xwm txheej kev cai rau feem ntau plugins 'kev ua tshwj xeeb. Feem ntau, cov no tuaj nyob rau hauv ib daim ntawv infinitive thiab yav dhau los koom nrog - qhov twg qhov infinitive (ex. show
) yog tshwm sim thaum pib ntawm ib qho kev tshwm sim, thiab nws yav dhau los kev koom tes (ex. shown
) yog tshwm sim ntawm qhov ua tiav ntawm qhov kev txiav txim.
Raws li ntawm 3.0.0, tag nrho cov txheej xwm Bootstrap yog namespaced.
Tag nrho cov txheej xwm infinitive muab preventDefault
functionality. Qhov no muab lub peev xwm los nres qhov kev txiav txim ua ntej nws pib.
Cov lus qhia thiab Popovers siv peb cov tshuaj ntxuav tes ua ke los ntxuav cov kev xaiv uas lees txais HTML.
Tus whiteList
nqi pib yog cov hauv qab no:
Yog tias koj xav ntxiv qhov tseem ceeb tshiab rau lub neej ntawd whiteList
koj tuaj yeem ua cov hauv qab no:
Yog tias koj xav hla peb cov tshuaj tua kab mob vim tias koj nyiam siv lub tsev qiv ntawv tshwj xeeb, piv txwv li DOMPurify , koj yuav tsum ua cov hauv qab no:
document.implementation.createHTMLDocument
Nyob rau hauv cov ntaub ntawv ntawm browsers uas tsis txhawb nqa document.implementation.createHTMLDocument
, xws li Internet Explorer 8, lub built-in sanitize muaj nuj nqi rov qab HTML li yog.
Yog tias koj xav ua kom huv hauv qhov no, thov qhia sanitizeFn
thiab siv lub tsev qiv ntawv sab nraud xws li DOMPurify .
Cov version ntawm txhua qhov ntawm Bootstrap's jQuery plugins tuaj yeem nkag tau los ntawm cov VERSION
cuab yeej ntawm plugin tus tsim. Piv txwv li, rau tooltip plugin:
Bootstrap's plugins tsis poob rov qab tshwj xeeb zoo nkauj thaum JavaScript raug kaw. Yog tias koj mob siab txog cov neeg siv kev paub dhau los hauv qhov no, siv <noscript>
los piav qhia qhov xwm txheej (thiab yuav ua li cas rov qhib JavaScript) rau koj cov neeg siv, thiab / lossis ntxiv koj tus kheej cov kev cai poob qis.
Bootstrap tsis ua haujlwm txhawb nqa JavaScript cov tsev qiv ntawv thib peb xws li Prototype lossis jQuery UI. Txawm hais tias .noConflict
thiab cov xwm txheej muaj npe, tej zaum yuav muaj teeb meem kev sib raug zoo uas koj yuav tsum tau kho ntawm koj tus kheej.
Rau kev hloov pauv yooj yim, suav nrog transition.js
ib zaug nrog rau lwm cov ntaub ntawv JS. Yog tias koj siv cov ntawv sau ua ke (lossis me me) bootstrap.js
, tsis tas yuav suav nrog qhov no - nws twb muaj lawm.
Transition.js yog tus pab cuam yooj yim rau transitionEnd
cov xwm txheej nrog rau CSS kev hloov pauv emulator. Nws tau siv los ntawm lwm cov plugins los kuaj xyuas CSS kev hloov pauv kev txhawb nqa thiab txhawm rau ntes dai hloov pauv.
Kev hloov pauv tuaj yeem cuam tshuam thoob ntiaj teb siv cov lus piav qhia JavaScript hauv qab no, uas yuav tsum tuaj tom qab transition.js
(lossis bootstrap.js
, bootstrap.min.js
raws li qhov xwm txheej) tau thauj khoom:
Modals yog streamlined, tab sis saj zawg zog, dialog prompts nrog yam tsawg kawg nkaus yuav tsum tau functionality thiab ntse defaults.
Nco ntsoov tsis txhob qhib lub modal thaum lwm qhov tseem pom. Qhia ntau tshaj ib qho modal ntawm ib lub sij hawm xav tau kev cai code.
Ib txwm sim tso ib qho modal's HTML code nyob rau hauv qhov chaw saum toj kawg nkaus hauv koj cov ntaub ntawv kom tsis txhob muaj lwm yam cuam tshuam rau lub modal qhov tsos thiab / lossis kev ua haujlwm.
Muaj qee qhov caveats hais txog kev siv modals ntawm mobile pab kiag li lawm. Saib peb cov ntaub ntawv txhawb nqa browser kom paub meej.
Vim li cas HTML5 txhais nws cov semantics, autofocus
HTML tus cwj pwm tsis muaj txiaj ntsig hauv Bootstrap modals. Txhawm rau ua tiav cov txiaj ntsig zoo ib yam, siv qee qhov kev cai JavaScript:
Ib tug rendered modal nrog header, lub cev, thiab txheej ntawm kev ua nyob rau hauv lub footer.
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.
Nco ntsoov ntxiv role="dialog"
thiab aria-labelledby="..."
, referencing lub npe modal, rau .modal
, thiab role="document"
rau .modal-dialog
nws tus kheej.
Tsis tas li ntawd, koj tuaj yeem muab cov lus piav qhia ntawm koj lub modal dialog nrog aria-describedby
rau ntawm .modal
.
Embedding YouTube yeeb yaj duab nyob rau hauv modals yuav tsum tau ntxiv JavaScript tsis nyob rau hauv Bootstrap kom cia li nres playback thiab ntau dua. Saib qhov pab tau Stack Overflow ncej kom paub ntau ntxiv.
Modals muaj ob qhov ntau thiab tsawg, muaj nyob ntawm cov chav kawm hloov kho kom muab tso rau ntawm ib qho .modal-dialog
.
Rau cov qauv uas tsuas yog tshwm sim ntau dua li ploj mus saib, tshem tawm cov .fade
chav kawm los ntawm koj cov ntawv cim modal.
Txhawm rau ua kom zoo dua ntawm Bootstrap kab sib chaws hauv ib qho qauv, tsuas yog zes .row
s nyob rau hauv .modal-body
thiab tom qab ntawd siv cov chav kawm kab sib chaws ib txwm muaj.
Muaj ib pawg ntawm cov nyees khawm uas txhua tus ua rau tib lub qauv, tsuas yog nrog cov ntsiab lus sib txawv me ntsis? Siv event.relatedTarget
thiab HTML data-*
cwj pwm (tejzaum nws ntawm jQuery ) kom sib txawv ntawm cov ntsiab lus ntawm lub modal nyob ntawm seb lub pob twg raug nias. Saib Modal Events docs kom paub meej txog relatedTarget
,
Lub modal plugin toggles koj zais cov ntsiab lus ntawm kev thov, ntawm cov ntaub ntawv cwj pwm lossis JavaScript. Nws kuj tseem ntxiv .modal-open
rau <body>
kom dhau qhov kev coj tus cwj pwm scrolling thiab tsim .modal-backdrop
kom muaj ib qho chaw nyem rau kev tshem tawm cov qauv qhia thaum nias sab nraum lub modal.
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 rau ib qho kev hloov pauv.
Hu rau modal nrog id myModal
nrog ib kab ntawm JavaScript:
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 los yog txoj hlua'static' |
muaj tseeb | Xws li ib qho modal-backdrop element. Xwb, qhia meej static rau 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 | Qhov kev xaiv no yog deprecated txij thaum v3.3.0 thiab tau raug tshem tawm hauv v4. Peb pom zoo kom siv cov neeg siv khoom-sab templateing lossis cov ntaub ntawv khi cov ntaub ntawv, lossis hu rau jQuery.load koj tus kheej. Yog hais tias ib qho chaw deb URL muab, cov ntsiab lus yuav raug thauj ib zaug ntawm jQuery txoj |
.modal(options)
Activates koj cov ntsiab lus raws li ib tug modal. Txais ib qho kev xaiv xaiv object
.
.modal('toggle')
Manually toggles ib modal. Rov qab mus rau tus neeg hu ua ntej lub modal tau tshwm sim los yog zais (piv txwv li ua ntej qhov shown.bs.modal
kev hidden.bs.modal
tshwm sim tshwm sim).
.modal('show')
Manually qhib lub modal. Rov qab mus rau tus neeg hu ua ntej lub modal tau tshwm sim tiag tiag (piv txwv li ua ntej qhov shown.bs.modal
kev tshwm sim tshwm sim).
.modal('hide')
Manually hides ib modal. Rov qab mus rau tus neeg hu ua ntej lub modal tau muab zais tiag tiag (piv txwv li ua ntej qhov hidden.bs.modal
xwm txheej tshwm sim).
.modal('handleUpdate')
Readjusts lub modal qhov chaw rau counter ib tug scrollbar nyob rau hauv cov ntaub ntawv ib tug yuav tsum tshwm sim, uas yuav ua rau lub modal dhia mus rau sab laug.
Tsuas yog xav tau thaum qhov siab ntawm modal hloov thaum nws qhib.
Bootstrap's modal class exposes ob peb txheej xwm rau hooking rau hauv modal functionality.
Tag nrho cov txheej xwm modal raug rho tawm haujlwm ntawm lub modal nws tus kheej (piv txwv li ntawm <div class="modal">
).
Hom xwm txheej | Kev piav qhia |
---|---|
show.bs.modal | Qhov xwm txheej no tua hluav taws tam sim ntawd thaum show hu ua piv txwv. Yog hais tias tshwm sim los ntawm ib tug nias, lub clicked caij yog muaj raws li cov relatedTarget cuab yeej ntawm qhov kev tshwm sim. |
ua.bs.modal | Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub modal tau pom rau tus neeg siv (yuav tos rau CSS kev hloov pauv kom tiav). Yog hais tias tshwm sim los ntawm ib tug nias, lub clicked caij yog muaj raws li cov relatedTarget cuab yeej ntawm qhov kev tshwm sim. |
nkaum.bs.modal | Qhov xwm txheej no raug rho tawm haujlwm tam sim ntawd thaum hide hu ua piv txwv txoj kev. |
zais.bs.modal | 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 kev hloov pauv kom tiav). |
loaded.bs.modal | Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub modal tau thauj cov ntsiab lus siv qhov remote kev xaiv. |
Ntxiv dropdown menus rau yuav luag txhua yam nrog no yooj yim plugin, nrog rau navbar, tabs, thiab tshuaj.
Los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript, lub dropdown plugin toggles zais cov ntsiab lus (dropdown menus) los ntawm toggling .open
chav kawm ntawm niam txiv cov npe khoom.
Ntawm cov khoom siv txawb, qhib lub dropdown ntxiv ib .dropdown-backdrop
qho chaw kais rau kaw cov ntawv qhia zaub mov thaum tapping sab nraum cov ntawv qhia zaub mov, qhov yuav tsum tau muaj rau kev txhawb nqa iOS. Qhov no txhais tau hais tias hloov los ntawm cov ntawv qhia zaub mov qhib mus rau cov ntawv qhia zaub mov txawv yuav tsum muaj tus kais dej ntxiv ntawm lub xov tooj ntawm tes.
Nco tseg: Tus data-toggle="dropdown"
cwj pwm yog tso siab rau kev kaw cov ntawv qhia zaub mov ntawm qib kev thov, yog li nws yog ib lub tswv yim zoo rau ib txwm siv nws.
Ntxiv data-toggle="dropdown"
rau qhov txuas lossis khawm kom toggle ib qho kev poob.
Txhawm rau khaws URLs tsis zoo nrog cov khawm txuas, siv tus data-target
cwj pwm tsis yog href="#"
.
Hu rau dropdowns ntawm JavaScript:
data-toggle="dropdown"
tseem xav tauTxawm hais tias koj hu koj lub dropdown ntawm JavaScript los yog siv cov ntaub ntawv-api, data-toggle="dropdown"
ib txwm yuav tsum muaj nyob rau hauv lub dropdown lub ntsiab lus.
Tsis muaj
$().dropdown('toggle')
Toggles lub dropdown ntawv qhia zaub mov ntawm ib tug muab navbar los yog tabbed navigation.
Tag nrho cov txheej xwm dropdown raug rho tawm haujlwm ntawm tus .dropdown-menu
niam txiv lub ntsiab.
Tag nrho cov txheej xwm dropdown muaj cov relatedTarget
cuab yeej, uas nws tus nqi yog toggling thauj tog rau nkoj caij.
Hom xwm txheej | Kev piav qhia |
---|---|
show.bs.dropdown | Qhov xwm txheej no tua hluav taws tam sim ntawd thaum hu ua yeeb yam piv txwv. |
pom.bs.dropdown | Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub dropdown tau pom rau tus neeg siv (yuav tos rau CSS kev hloov pauv, kom tiav). |
hide.bs.dropdown | Qhov xwm txheej no raug rho tawm haujlwm tam sim ntawd thaum txoj kev zais piv txwv tau raug hu. |
zais.bs.dropdown | Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub dropdown tiav lawm muab zais los ntawm tus neeg siv (yuav tos rau CSS hloov, kom tiav). |
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 qhov hloov pauv hauv chav kawm. Lub dropdown sub khoom yuav tsum highlighted thiab.
Ad leggings keytar, brunch id art party dolor laboure. 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.
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.
Occaecat commodo aliqua delectus. Fap craft npias deserunt skateboard ea. Lomo tsheb kauj vab txoj cai adipisicing banh mi, velit ea sunt qib tom ntej locavore ib leeg-hauv paus 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.
In incididunt echo park, officia deserunt mcsweeney's proident master cleanse thundercats sapiente veniam. Excepteur VHS elit, proident shoreditch +1 biodiesel laborum craft beer. Single-origin coffee wayfarers irure four loko, cupidatat terry richardson master cleanse. Assumenda you probably haven't heard of them art party fanny pack, tattooed nulla cardigan tempor ad. Proident wolf nesciunt sartorial keffiyeh eu banh mi sustainable. Elit wolf voluptate, lo-fi ea portland before they sold out four loko. Locavore enim nostrud mlkshk brooklyn nesciunt.
Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
Keytar twee blog, culpa messenger bag marfa xijpeem delectus food truck. 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.
Navbar txuas yuav tsum muaj lub hom phiaj id daws tau. Piv txwv li, ib qho <a href="#home">home</a>
yuav tsum sib haum rau ib yam dab tsi hauv DOM zoo li <div id="home"></div>
.
:visible
phiaj tsis quav ntsejLub hom phiaj cov ntsiab lus uas tsis yog :visible
raws li jQuery yuav raug tsis quav ntsej thiab lawv cov khoom siv nav yuav tsis raug qhia.
Tsis muaj teeb meem txoj kev siv, scrollspy yuav tsum tau siv ntawm position: relative;
lub caij koj nyob nraum spying. Feem ntau qhov no yog qhov <body>
. Thaum scrollspying ntawm cov ntsiab lus uas tsis yog lub <body>
, nco ntsoov muaj ib qho height
teeb tsa thiab overflow-y: scroll;
thov.
Txhawm rau yooj yim ntxiv scrollspy tus cwj pwm rau koj qhov topbar navigation, ntxiv data-spy="scroll"
rau lub caij koj xav soj ntsuam (feem ntau qhov no yuav yog <body>
). Tom qab ntawd ntxiv tus data-target
cwj pwm nrog tus ID lossis chav kawm ntawm niam txiv lub ntsiab ntawm ib qho Bootstrap .nav
tivthaiv.
Tom qab ntxiv position: relative;
hauv koj CSS, hu rau scrollspy ntawm JavaScript:
.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:
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. |
Hom xwm txheej | Kev piav qhia |
---|---|
activate.bs.scrollspy | Qhov xwm txheej no tua hluav taws thaum twg ib yam khoom tshiab tau qhib los ntawm scrollspy. |
Ntxiv ceev, dynamic tab functionality rau kev hloov mus los ntawm panes ntawm cov ntsiab lus hauv zos, txawm tias ntawm dropdown menus. Nested tabs tsis txaus siab.
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.
Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.
Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.
Cov plugin no txuas ntxiv cov tabbed navigation tivthaiv ntxiv cov chaw tabbable.
Qhib tabbable tabs ntawm JavaScript (txhua tab yuav tsum tau qhib ib tus zuj zus):
Koj tuaj yeem qhib ib tus neeg tab hauv ntau txoj hauv kev:
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 nav
thiab nav-tabs
cov chav kawm rau lub tab ul
yuav siv Bootstrap tab styling , thaum ntxiv cov nav
thiab nav-pills
cov chav kawm yuav siv tshuaj styling .
Txhawm rau ua kom cov tabs ploj mus, ntxiv .fade
rau txhua qhov .tab-pane
. Thawj tab pane yuav tsum tau .in
ua kom pom cov ntsiab lus thawj zaug.
$().tab
Activates lub tab element thiab cov ntsiab lus ntim. Tab yuav tsum muaj ib data-target
lossis ib lub href
hom phiaj rau lub thawv ntim hauv DOM. Hauv cov piv txwv saum toj no, cov tabs yog cov <a>
s nrog cov data-toggle="tab"
cwj pwm.
.tab('show')
Xaiv lub tab muab thiab qhia nws cov ntsiab lus cuam tshuam. Lwm lub tab uas tau xaiv yav dhau los yuav tsis raug xaiv thiab nws cov ntsiab lus cuam tshuam raug muab zais. Rov qab mus rau tus neeg hu ua ntej lub tab pane tau tshwm sim tiag tiag (piv txwv li ua ntej qhov shown.bs.tab
xwm txheej tshwm sim).
Thaum pom ib lub tab tshiab, cov xwm txheej hluav taws kub hauv qhov kev txiav txim hauv qab no:
hide.bs.tab
(ntawm lub tab active tam sim no)show.bs.tab
(ntawm qhov yuav tsum tau qhia tab)hidden.bs.tab
(nyob rau yav dhau los active tab, tib yam li rau qhov hide.bs.tab
kev tshwm sim)shown.bs.tab
(ntawm lub tab tshiab uas nyuam qhuav tshwm sim, tib yam li rau qhov show.bs.tab
kev tshwm sim)Yog tias tsis muaj tab twb ua haujlwm lawm, ces cov xwm txheej hide.bs.tab
thiab hidden.bs.tab
cov xwm txheej yuav tsis raug rho tawm haujlwm.
Hom xwm txheej | Kev piav qhia |
---|---|
show.bs.tab | Qhov kev tshwm sim no tua hluav taws ntawm tab qhia, tab sis ua ntej tab tshiab tau tshwm sim. Siv event.target thiab event.relatedTarget tsom rau lub tab active thiab yav dhau los active tab (yog tias muaj) feem. |
ua.bs.tab | Qhov kev tshwm sim no tua hluav taws ntawm tab qhia tom qab tau pom tab. Siv event.target thiab event.relatedTarget tsom rau lub tab active thiab yav dhau los active tab (yog tias muaj) feem. |
hide.bs.tab | Qhov kev tshwm sim no tua hluav taws thaum lub tab tshiab yuav tsum tau tshwm sim (thiab yog li lub tab yav dhau los yuav tsum tau muab zais). Siv event.target thiab event.relatedTarget tsom rau cov tab tam sim no thiab cov tshiab sai sai-rau-yuav-ua haujlwm tab, feem. |
hidden.bs.tab | Qhov kev tshwm sim no tshwm sim tom qab lub tab tshiab tau tshwm sim (thiab yog li lub tab active yav dhau los tau muab zais). Siv event.target thiab event.relatedTarget tsom mus rau lub tab active yav dhau los thiab cov tshiab tab tshiab, raws li. |
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.
Cov lus qhia nrog xoom-ntev lub npe yeej tsis tshwm sim.
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 xaiv muaj: sab saum toj, sab xis, hauv qab, thiab sab laug dlhos.
Rau cov laj thawj ua tau zoo, Tooltip thiab Popover cov ntaub ntawv-apis yog opt-in, txhais tau tias koj yuav tsum pib pib lawv tus kheej .
Ib txoj hauv kev los pib tag nrho cov lus qhia ntawm nplooj ntawv yuav yog xaiv lawv los ntawm lawv data-toggle
tus cwj pwm:
Lub tooltip plugin tsim cov ntsiab lus thiab kos npe rau ntawm qhov kev thov, thiab los ntawm lub neej ntawd tso cov lus qhia tom qab lawv lub ntsiab lus.
Tig lub cuab yeej ntawm JavaScript:
Qhov yuav tsum tau kos npe rau cov lus qhia tsuas yog tus data
cwj pwm thiab title
ntawm HTML lub caij koj xav kom muaj cov lus qhia. Lub generated markup ntawm ib tug tooltip yog qhov yooj yim, tab sis nws yuav tsum tau ib txoj hauj lwm (los ntawm lub neej ntawd, teem los top
ntawm lub plugin).
Qee lub sij hawm koj xav ntxiv cov lus qhia rau lub hyperlink uas qhwv ntau kab. Lub neej ntawd tus cwj pwm ntawm lub tooltip plugin yog nruab nrab nws horizontally thiab vertically. Ntxiv white-space: nowrap;
rau koj cov anchors kom zam qhov no.
Thaum siv cov lus qhia ntawm cov ntsiab lus hauv ib .btn-group
lossis ib qho .input-group
, lossis ntawm cov lus hais txog cov ntsiab lus ( <td>
, <th>
, , <tr>
, <thead>
, , <tbody>
, <tfoot>
), koj yuav tsum tau qhia qhov kev xaiv container: 'body'
(cov ntaub ntawv hauv qab no) kom tsis txhob muaj kev phiv tsis zoo (xws li lub caij loj hlob thiab / los yog poob nws cov ces kaum sib npaug thaum cov lus qhia tau tshwm sim).
Rau cov neeg siv navigating nrog cov keyboard, thiab tshwj xeeb tshaj yog cov neeg siv cov cuab yeej pab, koj tsuas yog yuav tsum ntxiv cov lus qhia rau cov keyboard-focusable ntsiab xws li kev sib txuas, daim ntawv tswj, lossis ib qho kev txiav txim siab nrog tus tabindex="0"
cwj pwm.
Txhawm rau ntxiv cov lus qhia rau ib disabled
lossis .disabled
lub caij, muab lub ntsiab rau hauv ib qho <div>
thiab siv cov lus qhia rau qhov ntawd <div>
.
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=""
.
Nco ntsoov tias yog vim li cas kev ruaj ntseg cov sanitize
, sanitizeFn
thiab whiteList
cov kev xaiv tsis tuaj yeem muab siv cov ntaub ntawv cwj pwm.
Lub npe | Hom | Default | Kev piav qhia |
---|---|---|---|
animation | boolean | muaj tseeb | Siv CSS hloov pauv mus rau cov lus qhia |
thawv | hlua | cuav | cuav | Appends lub tooltip rau ib lub caij tshwj xeeb. |
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: |
html | boolean | cuav | Ntxig HTML rau hauv cov lus qhia. Yog tias tsis tseeb, jQuery txoj text kev 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 tso lub cuab yeej - saum | hauv qab | sab laug | txoj cai | auto. Thaum muaj nuj nqi yog siv los txiav txim qhov kev tso kawm, nws raug hu nrog lub tooltip DOM node raws li nws thawj qhov kev sib cav thiab lub triggering ntsiab DOM node raws li nws thib ob. Cov |
xaiv | txoj hlua | cuav | Yog hais tias muaj ib tug selector, tooltip khoom yuav delegated mus rau lub hom phiaj teev. Hauv kev xyaum, qhov no yog siv los kuj siv cov lus qhia rau dynamically ntxiv DOM ntsiab ( jQuery.on kev txhawb nqa). Saib qhov no thiab ib qho piv txwv qhia . |
tus qauv | txoj hlua | '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' |
Base HTML siv thaum tsim cov lus qhia. Cov cuab yeej cuab tam
Cov txheej txheem wrapper sab nraud yuav tsum muaj |
lub npe | hlua | muaj nuj nqi | '' | Default title value yog Yog tias muaj kev ua haujlwm tau muab, nws yuav raug hu nrog nws cov |
ua rau | txoj hlua | 'hover focus' | Yuav ua li cas tooltip yog triggered - nyem | hover | tsom | phau ntawv. Koj tuaj yeem hla ntau qhov ua rau; cais lawv nrog ib qho chaw. manual tsis tuaj yeem ua ke nrog lwm qhov ua rau. |
saib | hlua | khoom | muaj nuj nqi | { selector: 'lub cev', padding: 0 } | Khaws cov lus qhia nyob rau hauv cov ciam teb ntawm lub caij no. Yog tias muaj kev ua haujlwm tau muab, nws raug hu nrog lub ntsiab lus DOM ntawm nws qhov kev sib cav nkaus xwb. Cov |
ua kom huv | boolean | muaj tseeb | Qhib lossis kaw qhov kev huv huv. Yog tias qhib 'template' , 'content' thiab 'title' cov kev xaiv yuav raug ntxuav. |
daim ntawv dawb | khoom | Default tus nqi | Yam khoom uas muaj cov cwj pwm tso cai thiab cov cim npe |
huv Fn | null | muaj nuj nqi | null | Ntawm no koj tuaj yeem muab koj tus kheej ua haujlwm huv. Qhov no tuaj yeem pab tau yog tias koj xav siv lub tsev qiv ntawv tshwj xeeb los ua kom huv. |
Cov kev xaiv rau tus kheej cov lus qhia tuaj yeem hloov pauv tau los ntawm kev siv cov ntaub ntawv cwj pwm, raws li tau piav qhia saum toj no.
$().tooltip(options)
Txuas tus tooltip handler rau ib qho khoom sau.
.tooltip('show')
Qhia ib lub ntsiab lus qhia. Rov qab mus rau tus neeg hu ua ntej cov lus qhia tau tshwm sim tiag tiag (piv txwv li ua ntej qhov shown.bs.tooltip
xwm txheej tshwm sim). Qhov no suav hais tias yog "phau ntawv" tshwm sim ntawm cov lus qhia. Cov lus qhia nrog xoom-ntev lub npe yeej tsis tshwm sim.
.tooltip('hide')
Hide ib lub ntsiab lus qhia. Rov qab mus rau tus neeg hu ua ntej cov lus qhia tau muab zais tiag tiag (piv txwv li ua ntejhidden.bs.tooltip
xwm txheej tshwm sim). Qhov no suav hais tias yog "phau ntawv" tshwm sim ntawm cov lus qhia.
.tooltip('toggle')
Toggles ib lub ntsiab lus qhia. Rov qab mus rau tus neeg hu ua ntej cov lus qhia tau tshwm sim los yog muab zais (piv txwv li ua ntej qhov shown.bs.tooltip
kev hidden.bs.tooltip
tshwm sim tshwm sim). Qhov no suav hais tias yog "phau ntawv" tshwm sim ntawm cov lus qhia.
.tooltip('destroy')
Nias thiab rhuav tshem cov ntsiab lus ntawm cov cuab yeej. Cov lus qhia uas siv delegation (uas yog tsim los ntawm selector
kev xaiv ) tsis tuaj yeem raug rhuav tshem ib tus zuj zus ntawm cov xeeb leej xeeb ntxwv.
Hom xwm txheej | Kev piav qhia |
---|---|
show.bs.tooltip | Qhov xwm txheej no tua hluav taws tam sim ntawd thaum show hu ua piv txwv. |
qhia.bs.tooltip | Qhov kev tshwm sim no raug rho tawm haujlwm thaum cov lus qhia tau ua kom pom rau tus neeg siv (yuav tos rau CSS kev hloov pauv kom tiav). |
hide.bs.tooltip | Qhov xwm txheej no raug rho tawm haujlwm tam sim ntawd thaum hide hu ua piv txwv txoj kev. |
zais.bs.tooltip | Qhov kev tshwm sim no raug rho tawm haujlwm thaum cov lus qhia tau ua tiav tau muab zais los ntawm tus neeg siv (yuav tos rau CSS kev hloov pauv kom tiav). |
inserted.bs.tooltip | Qhov kev tshwm sim no raug rho tawm haujlwm tom qab qhov show.bs.tooltip tshwm sim thaum lub cuab yeej template tau ntxiv rau DOM. |
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.
Popovers uas nws ob lub npe thiab cov ntsiab lus yog xoom-ntev yeej tsis tshwm sim.
Popovers xav tau lub tooltip plugin kom muab tso rau hauv koj lub version ntawm Bootstrap.
Rau cov laj thawj ua tau zoo, Tooltip thiab Popover cov ntaub ntawv-apis yog opt-in, txhais tau tias koj yuav tsum pib pib lawv tus kheej .
Ib txoj hauv kev los pib tag nrho cov popovers ntawm nplooj ntawv yuav yog xaiv lawv los ntawm lawv data-toggle
tus cwj pwm:
Thaum siv popovers ntawm cov ntsiab lus hauv ib .btn-group
lossis ib qho .input-group
, lossis ntawm cov lus hais txog ( <td>
, <th>
, <tr>
, , <thead>
, <tbody>
, <tfoot>
), koj yuav tsum tau qhia qhov kev xaiv container: 'body'
(cov ntaub ntawv hauv qab no) kom tsis txhob muaj kev phiv tsis zoo (xws li lub caij loj hlob thiab / los yog poob nws puag ncig thaum lub popover tshwm sim).
Txhawm rau ntxiv ib qho popover rau ib disabled
lossis .disabled
lub caij, muab cov khoom tso rau hauv ib qho <div>
thiab siv lub popover rau qhov ntawd <div>
.
Qee lub sij hawm koj xav ntxiv ib qho popover rau ib qho hyperlink uas qhwv ntau kab. Lub neej ntawd tus cwj pwm ntawm lub popover plugin yog nruab nrab ntawm nws kab rov tav thiab ntsug. Ntxiv white-space: nowrap;
rau koj cov anchors kom zam qhov no.
Plaub txoj kev xaiv muaj: sab saum toj, sab xis, hauv qab, thiab sab laug dlhos.
Sed posuere consectetur yog nyob rau hauv lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Sed posuere consectetur yog nyob rau hauv lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Sed posuere consectetur yog nyob rau hauv lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Sed posuere consectetur yog nyob rau hauv lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Siv qhov focus
ua kom tshem tawm popovers ntawm qhov nyem tom ntej uas tus neeg siv ua.
Txhawm rau kom tus neeg hla browser thiab tus cwj pwm hla lub platform, koj yuav tsum siv lub <a>
cim npe, tsis yog lub <button>
cim, thiab koj kuj yuav tsum suav nrog role="button"
thiab tabindex
cov cwj pwm.
Qhib popovers ntawm JavaScript:
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=""
.
Nco ntsoov tias yog vim li cas kev ruaj ntseg cov sanitize
, sanitizeFn
thiab whiteList
cov kev xaiv tsis tuaj yeem muab siv cov ntaub ntawv cwj pwm.
Lub npe | Hom | Default | Kev piav qhia |
---|---|---|---|
animation | boolean | muaj tseeb | Siv CSS ploj mus rau qhov popover |
thawv | hlua | cuav | cuav | Appends lub popover rau ib lub caij tshwj xeeb. |
cov ntsiab lus | hlua | muaj nuj nqi | '' | Default ntsiab lus tus nqi yog Yog tias muaj nuj nqi tau muab, nws yuav raug hu nrog nws cov |
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: |
html | boolean | cuav | Ntxig HTML rau hauv popover. Yog tias tsis tseeb, jQuery txoj text kev 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 - sab saum toj | hauv qab | sab laug | txoj cai | auto. Thaum muaj nuj nqi yog siv los txiav txim qhov kev tso kawm, nws raug hu nrog popover DOM node raws li nws thawj qhov kev sib cav thiab lub triggering ntsiab DOM node raws li nws thib ob. Cov |
xaiv | txoj hlua | cuav | Yog tias muaj ib tus neeg xaiv tau muab, cov khoom popover yuav raug xa mus rau cov phiaj xwm tshwj xeeb. Hauv kev xyaum, qhov no yog siv los ua kom cov ntsiab lus HTML dynamic kom muaj popovers ntxiv. Saib qhov no thiab ib qho piv txwv qhia . |
tus qauv | txoj hlua | '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>' |
Base HTML siv thaum tsim cov popover. Popover's Popover's
Cov txheej txheem wrapper sab nraud yuav tsum muaj |
lub npe | hlua | muaj nuj nqi | '' | Default title value yog Yog tias muaj nuj nqi tau muab, nws yuav raug hu nrog nws cov |
ua rau | txoj hlua | 'nias' | Yuav ua li cas popover yog triggered - nyem | hover | tsom | phau ntawv. Koj tuaj yeem hla ntau qhov ua rau; cais lawv nrog ib qho chaw. manual tsis tuaj yeem ua ke nrog lwm qhov ua rau. |
saib | hlua | khoom | muaj nuj nqi | { selector: 'lub cev', padding: 0 } | Khaws lub popover hauv thaj tsam ntawm lub caij no. Yog tias muaj kev ua haujlwm tau muab, nws raug hu nrog lub ntsiab lus DOM ntawm nws qhov kev sib cav nkaus xwb. Cov |
ua kom huv | boolean | muaj tseeb | Qhib lossis kaw qhov kev huv huv. Yog tias qhib 'template' , 'content' thiab 'title' cov kev xaiv yuav raug ntxuav. |
daim ntawv dawb | khoom | Default tus nqi | Yam khoom uas muaj cov cwj pwm tso cai thiab cov cim npe |
huv Fn | null | muaj nuj nqi | null | Ntawm no koj tuaj yeem muab koj tus kheej ua haujlwm huv. Qhov no tuaj yeem pab tau yog tias koj xav siv lub tsev qiv ntawv tshwj xeeb los ua kom huv. |
Kev xaiv rau ib tus neeg popovers tuaj yeem hloov tau los ntawm kev siv cov ntaub ntawv tus cwj pwm, raws li tau piav qhia saum toj no.
$().popover(options)
Initializes popovers rau ib qho khoom sau.
.popover('show')
Qhia ib lub ntsiab lus popover. Rov qab mus rau tus neeg hu ua ntej qhov popover tau tshwm sim tiag tiag (piv txwv li ua ntej qhov shown.bs.popover
xwm txheej tshwm sim). Qhov no suav hais tias yog "phau ntawv" ua rau lub popover. Popovers uas nws ob lub npe thiab cov ntsiab lus yog xoom-ntev yeej tsis tshwm sim.
.popover('hide')
Hide ib lub ntsiab lus popover. Rov qab mus rau tus neeg hu ua ntej lub popover tau muab zais (piv txwv li ua ntejhidden.bs.popover
xwm txheej tshwm sim). Qhov no suav hais tias yog "phau ntawv" ua rau lub popover.
.popover('toggle')
Toggles ib lub ntsiab lus popover. Rov qab mus rau tus neeg hu ua ntej lub popover tau tshwm sim los yog zais (piv txwv li ua ntej qhov shown.bs.popover
kev hidden.bs.popover
tshwm sim tshwm sim). Qhov no suav hais tias yog "phau ntawv" ua rau lub popover.
.popover('destroy')
Nias thiab rhuav tshem lub ntsiab lus popover. Popovers uas siv delegation (uas yog tsim los ntawm selector
kev xaiv ) tsis tuaj yeem raug rhuav tshem ib tus zuj zus ntawm cov xeeb leej xeeb ntxwv.
Hom xwm txheej | Kev piav qhia |
---|---|
show.bs.popover | Qhov xwm txheej no tua hluav taws tam sim ntawd thaum show hu ua piv txwv. |
pom.bs.popover | Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub popover tau pom rau tus neeg siv (yuav tos rau CSS kev hloov pauv kom tiav). |
hide.bs.popover | Qhov xwm txheej no raug rho tawm haujlwm tam sim ntawd thaum hide hu ua piv txwv txoj kev. |
zais.bs.popover | Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub popover tiav lawm muab zais los ntawm tus neeg siv (yuav tos rau CSS kev hloov pauv kom tiav). |
inserted.bs.popover | Qhov kev tshwm sim no raug rho tawm haujlwm tom qab qhov show.bs.popover tshwm sim thaum lub popover template tau ntxiv rau DOM. |
Ntxiv tso tawm haujlwm rau tag nrho cov lus ceeb toom nrog cov plugin no.
Thaum siv lub .close
pob, nws yuav tsum yog thawj tus me nyuam ntawm cov ntawv .alert-dismissible
thiab tsis muaj cov ntsiab lus ntawm cov ntawv yuav tuaj ua ntej nws nyob rau hauv lub cim.
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.
Tsuas yog ntxiv data-dismiss="alert"
rau koj lub khawm kaw kom tau txais kev ceeb toom kaw ua haujlwm. Kaw ib qho kev ceeb toom tshem tawm ntawm DOM.
Txhawm rau kom koj cov lus ceeb toom siv cov animation thaum kaw, xyuas kom lawv muaj cov .fade
chav .in
kawm twb tau thov rau lawv.
$().alert()
Ua kom ceeb toom mloog rau cov xwm txheej nyem ntawm cov xeeb leej xeeb ntxwv uas muaj tus data-dismiss="alert"
cwj pwm. (Tsis tsim nyog thaum siv data-api's auto-initialization.)
$().alert('close')
Kaw ib qho kev ceeb toom los ntawm kev tshem tawm ntawm DOM. Yog lawm .fade
thiab.in
cov chav kawm muaj nyob rau ntawm lub caij, lub ceeb toom yuav ploj mus ua ntej nws yuav raug tshem tawm.
Bootstrap's alert plugin nthuav tawm ob peb txheej xwm rau hooking rau hauv kev ceeb toom ua haujlwm.
Hom xwm txheej | Kev piav qhia |
---|---|
close.bs.alert | Qhov xwm txheej no tua hluav taws tam sim ntawd thaum close hu ua piv txwv. |
kaw.bs.alert | 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). |
Ua ntau nrog cov nyees khawm. Tswj khawm hais los yog tsim pab pawg ntawm cov nyees khawm rau ntau yam xws li toolbars.
Firefox txuas ntxiv tsim cov xeev tswj (kev xiam oob khab thiab kuaj xyuas) hla nplooj ntawv . Ib qho kev daws teeb meem rau qhov no yog siv autocomplete="off"
. Saib Mozilla kab laum #654072 .
Ntxiv data-loading-text="Loading..."
rau siv lub xeev loading ntawm ib lub pob.
Qhov no feature yog deprecated txij thaum v3.3.5 thiab tau raug tshem tawm nyob rau hauv v4.
Rau lub hom phiaj ntawm kev ua qauv qhia no, peb siv data-loading-text
thiab $().button('loading')
, tab sis qhov ntawd tsis yog lub xeev nkaus xwb uas koj tuaj yeem siv. Saib ntxiv ntawm qhov no hauv qab no hauv cov $().button(string)
ntaub ntawv .
Ntxiv data-toggle="button"
rau qhib toggling ntawm ib lub pob.
.active
thiabaria-pressed="true"
Rau cov nyees khawm pre-toggled, koj yuav tsum ntxiv cov .active
chav kawm thiab tus aria-pressed="true"
cwj pwm rau button
koj tus kheej.
Ntxiv data-toggle="buttons"
rau lub .btn-group
thawv uas muaj lub thawv ntawv lossis xov tooj cua nkag los ua kom toggling hauv lawv cov qauv.
.active
Rau cov kev xaiv ua ntej, koj yuav tsum ntxiv cov .active
chav kawm rau cov tswv yim ntawm label
koj tus kheej.
Yog hais tias lub xeev checkbox khawm hloov tshiab yam tsis tau tua ib qho click
kev tshwm sim ntawm lub pob (xws li los ntawm <input type="reset">
los yog los ntawm kev teeb tsa cov checked
cuab yeej ntawm cov tswv yim), koj yuav tsum toggle .active
chav kawm ntawm cov tswv yim ntawm label
koj tus kheej.
$().button('toggle')
Toggles thawb lub xeev. Muab lub pob kom pom tias nws tau qhib.
$().button('reset')
Resets khawm lub xeev - swaps ntawv rau cov ntawv qub. Txoj kev no yog asynchronous thiab xa rov qab ua ntej qhov rov pib dua tau ua tiav.
$().button(string)
Hloov cov ntawv mus rau cov ntaub ntawv teev cov ntawv hauv xeev.
Yooj yim plugin uas siv ib tug puv tes ntawm cov chav kawm kom yooj yim toggle cwj pwm.
Collapse yuav tsum muaj qhov hloov pauv plugin kom suav nrog hauv koj lub version ntawm Bootstrap.
Nyem rau cov nyees khawm hauv qab no los qhia thiab zais lwm lub ntsiab lus ntawm kev hloov hauv chav kawm:
.collapse
zais cov ntsiab lus.collapsing
yog siv thaum lub sij hawm hloov.collapse.in
qhia cov ntsiab lusKoj tuaj yeem siv qhov txuas nrog tus href
cwj pwm, lossis khawm nrog tus data-target
cwj pwm. Hauv ob qho xwm txheej, qhov data-toggle="collapse"
yuav tsum tau ua.
Txuas ntxiv qhov kev coj cwj pwm tsis zoo los tsim ib qho accordion nrog lub vaj huam sib luag.
Nws tseem tuaj yeem hloov pauv .panel-body
s nrog .list-group
s.
Nco ntsoov ntxiv aria-expanded
rau lub caij tswj. Tus cwj pwm no qhia meej meej txog lub xeev tam sim no ntawm lub caij sib tsoo rau kev tshuaj ntsuam nyeem ntawv thiab cov cuab yeej pabcuam zoo sib xws. Yog hais tias lub caij collapsible raug kaw los ntawm lub neej ntawd, nws yuav tsum muaj tus nqi ntawm aria-expanded="false"
. Yog tias koj tau teeb tsa lub caij collapsible kom qhib los ntawm lub neej ntawd siv cov in
chav kawm, teem caij aria-expanded="true"
rau kev tswj hwm. Lub plugin yuav cia li toggle tus cwj pwm no raws li seb puas tau qhib lossis kaw.
Tsis tas li ntawd, yog tias koj lub ntsiab tswj yog tsom rau ib qho kev sib tsoo nkaus xwb - piv txwv li tus data-target
cwj pwm yog taw tes rau tus id
xaiv - koj tuaj yeem ntxiv tus aria-controls
cwj pwm ntxiv rau cov khoom tswj, uas muaj cov id
khoom sib tsoo. Cov ntawv nyeem niaj hnub no thiab cov thev naus laus zis zoo sib xws ua rau siv cov cwj pwm no los muab cov neeg siv nrog cov shortcuts ntxiv rau kev taw qhia ncaj qha rau lub caij sib tsoo nws tus kheej.
Lub cev qhuav dej siv ob peb chav kawm los daws qhov hnyav nqa:
.collapse
zais cov ntsiab lus.collapse.in
qhia cov ntsiab lus.collapsing
ntxiv thaum qhov kev hloov pauv pib, thiab tshem tawm thaum nws tiavCov chav kawm no tuaj yeem pom hauv component-animations.less
.
Tsuas yog ntxiv data-toggle="collapse"
thiab ib qho data-target
rau lub caij kom tau txais kev tswj hwm ntawm lub caij collapsible. Tus data-target
cwj pwm lees txais CSS xaiv los siv lub cev qhuav dej rau. Nco ntsoov ntxiv cov chav kawm collapse
rau 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 pab 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.
Qhib manually nrog:
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 hais tias muaj ib tug selector, ces tag nrho cov collapsible ntsiab nyob rau hauv cov niam txiv uas tau teev tseg yuav raug kaw thaum cov khoom no collapsible qhia. (zoo ib yam li kev coj cwj pwm accordion - qhov no yog nyob ntawm panel chav kawm) |
toggle | boolean | muaj tseeb | Toggles lub caij collapsible ntawm invocation |
.collapse(options)
Activates koj cov ntsiab lus raws li ib tug collapsible caij. Txais ib qho kev xaiv xaiv object
.
.collapse('toggle')
Toggles lub caij collapsible kom pom los yog zais. Rov qab mus rau tus neeg hu ua ntej lub caij collapsible tau tshwm sim los yog zais (piv txwv li ua ntej qhov shown.bs.collapse
kev hidden.bs.collapse
tshwm sim tshwm sim).
.collapse('show')
Qhia ib lub caij collapsible. Rov qab mus rau tus neeg hu ua ntej lub caij collapsible tau tshwm sim tiag tiag (piv txwv li ua ntej qhov shown.bs.collapse
xwm txheej tshwm sim).
.collapse('hide')
Hide ib lub caij collapsible. Rov qab mus rau tus neeg hu ua ntej lub caij collapsible tau muab zais tiag tiag (piv txwv li ua ntej qhov hidden.bs.collapse
xwm txheej tshwm sim).
Bootstrap's collapse class exposes ob peb txheej xwm rau hooking mus rau hauv vau functionality.
Hom xwm txheej | Kev piav qhia |
---|---|
show.bs.collapse | Qhov xwm txheej no tua hluav taws tam sim ntawd thaum show hu ua piv txwv. |
pom.bs.collapse | 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). |
hide.bs.collapse | Qhov kev tshwm sim no raug rho tawm haujlwm tam sim ntawd thaum hide hu ua txoj kev. |
zais.bs.collapse | Qhov xwm txheej 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). |
Ib qho slideshow tivthaiv rau kev caij tsheb kauj vab los ntawm cov khoom, zoo li lub carousel. Nested carousels tsis txaus siab.
Cov khoom siv carousel feem ntau tsis ua raws li cov qauv kev nkag mus tau yooj yim. Yog tias koj yuav tsum ua raws li, thov xav txog lwm txoj hauv kev los nthuav qhia koj cov ntsiab lus.
Bootstrap tsuas yog siv CSS3 rau nws cov duab, tab sis Internet Explorer 8 & 9 tsis txhawb nqa cov khoom tsim nyog CSS. Yog li, tsis muaj kev hloov pauv cov animations thaum siv cov browsers no. Peb tau txhob txwm txiav txim siab tsis suav nrog jQuery-based fallbacks rau kev hloov pauv.
Cov .active
chav kawm yuav tsum tau ntxiv rau ib qho ntawm cov slides. Txwv tsis pub, lub carousel yuav tsis pom.
Cov chav kawm .glyphicon .glyphicon-chevron-left
thiab .glyphicon .glyphicon-chevron-right
cov chav kawm tsis tas yuav tsum muaj rau kev tswj hwm. Bootstrap muab .icon-prev
thiab .icon-next
ua lwm yam unicode dawb.
Ntxiv cov ntawv sau rau koj cov slides yooj yim nrog cov .carousel-caption
khoom hauv ib qho twg .item
. Qhov chaw tsuas yog hais txog ib qho kev xaiv HTML nyob rau hauv qhov ntawd thiab nws yuav raug txiav thiab formatted.
Carousels yuav tsum tau siv ib qho id
ntawm lub thawv sab nraud (lub .carousel
) rau kev tswj xyuas carousel kom ua haujlwm zoo. Thaum ntxiv ntau lub carousel, lossis thaum hloov lub carousel id
, nco ntsoov hloov kho cov kev tswj hwm.
Siv cov ntaub ntawv cwj pwm kom yooj yim tswj txoj hauj lwm ntawm lub carousel. data-slide
lees txais cov lus tseem ceeb prev
lossis next
, uas hloov txoj haujlwm swb txheeb ze rau nws txoj haujlwm tam sim no. Xwb, siv data-slide-to
kom dhau qhov ntsuas qhov ntsuas tsis sib haum mus rau lub carousel data-slide-to="2"
, uas hloov txoj haujlwm swb mus rau qhov ntsuas tshwj xeeb pib nrog 0
.
Tus data-ride="carousel"
cwj pwm yog siv los khij lub carousel li animating pib ntawm nplooj ntawv load. Nws tsis tuaj yeem siv ua ke nrog (rov ua dua thiab tsis tsim nyog) qhia meej JavaScript pib ntawm tib lub carousel.
Hu rau carousel manually nrog:
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-interval=""
.
Lub npe | hom | ua ntej | piav qhia |
---|---|---|---|
lub sijhawm | tus lej | 5000 | Lub sijhawm ncua sijhawm ntawm kev caij tsheb kauj vab ib yam khoom. Yog hais tias tsis tseeb, carousel yuav tsis cia li voj voog. |
nres | hlua | null | "hover" | Yog tias tau teeb tsa "hover" , nres lub caij tsheb kauj vab ntawm lub carousel rau mouseenter thiab rov pib caij tsheb kauj vab ntawm lub carousel rau mouseleave . Yog tias teem rau null , hovering hla lub carousel yuav tsis nres nws. |
qhwv | boolean | muaj tseeb | Txawm hais tias lub carousel yuav tsum tsis tu ncua los yog muaj zog nres. |
keyboard | boolean | muaj tseeb | Seb lub carousel yuav tsum teb rau cov xwm txheej keyboard. |
.carousel(options)
Pib lub carousel nrog ib qho kev xaiv xaiv object
thiab pib caij tsheb kauj vab los ntawm cov khoom.
.carousel('cycle')
Cycles los ntawm cov khoom carousel ntawm sab laug mus rau sab xis.
.carousel('pause')
Nres lub carousel los ntawm kev caij tsheb kauj vab los ntawm cov khoom.
.carousel(number)
Cycles lub carousel rau ib lub thav duab (0 raws li, zoo ib yam li ib qho array).
.carousel('prev')
Lub voj voog mus rau qhov khoom dhau los.
.carousel('next')
Cycles mus rau yam khoom tom ntej.
Bootstrap's carousel class exposes ob txheej xwm rau hooking rau hauv carousel functionality.
Ob qho xwm txheej muaj cov khoom nram qab no ntxiv:
direction
: Cov kev taw qhia uas lub carousel zawv zawg (txawm "left"
los yog "right"
).relatedTarget
: Lub caij DOM uas tau swb rau hauv qhov chaw ua cov khoom nquag.Tag nrho cov xwm txheej carousel raug rho tawm haujlwm ntawm lub carousel nws tus kheej (piv txwv li ntawm <div class="carousel">
).
Hom xwm txheej | Kev piav qhia |
---|---|
swb.bs.carousel | Qhov xwm txheej no tua hluav taws tam sim ntawd thaum tus slide txheej txheem piv txwv raug hu. |
swb.bs.carousel | Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub carousel tau ua tiav nws txoj kev hloov pauv. |
Lub affix plugin toggles position: fixed;
rau thiab tawm, emulating cov nyhuv pom nrog position: sticky;
. Lub subnavigation ntawm sab xis yog qhov nyob deb ntawm lub affix plugin.
Siv lub affix plugin ntawm cov ntaub ntawv cwj pwm lossis manually nrog koj tus kheej JavaScript. Hauv ob qho xwm txheej, koj yuav tsum muab CSS rau qhov chaw thiab qhov dav ntawm koj cov ntsiab lus affixed.
Nco tseg: Tsis txhob siv lub affix plugin ntawm ib lub caij uas muaj nyob rau hauv ib tug kuj positioned caij, xws li ib tug rub los yog thawb kem, vim yog ib tug Safari rendering kab .
Lub affix plugin toggles ntawm peb chav kawm, txhua tus sawv cev rau ib lub xeev tshwj xeeb: .affix
, .affix-top
, thiab .affix-bottom
. Koj yuav tsum muab cov qauv, tshwj tsis yog position: fixed;
rau .affix
, rau cov chav kawm no koj tus kheej (ywj siab ntawm qhov plugin no) los tswj cov haujlwm tiag tiag.
Nov yog yuav ua li cas lub affix plugin ua haujlwm:
.affix-top
los qhia tias lub caij yog nyob rau hauv nws txoj haujlwm saum toj kawg nkaus. Hauv qhov no, tsis muaj CSS qhov yuav tsum tau ua..affix
hloov .affix-top
thiab teeb tsa position: fixed;
(muab los ntawm Bootstrap's CSS)..affix
nrog .affix-bottom
. Txij li thaum offsets yog xaiv tau, teeb tsa ib qho xav kom koj teeb tsa CSS tsim nyog. Hauv qhov no, ntxiv position: absolute;
thaum tsim nyog. Lub plugin siv cov ntaub ntawv tus cwj pwm lossis kev xaiv JavaScript los txiav txim qhov twg los tso lub ntsiab lus los ntawm qhov ntawd.Ua raws li cov kauj ruam saum toj no los teeb koj CSS rau ob qho ntawm cov kev xaiv siv hauv qab no.
Txhawm rau yooj yim ntxiv affix tus cwj pwm rau txhua lub caij, tsuas yog ntxiv data-spy="affix"
rau lub caij koj xav soj ntsuam. Siv offsets los txhais thaum twg los toggle pinning ntawm ib lub caij.
Hu rau affix plugin ntawm JavaScript:
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 sab saum toj thiab hauv qab cov lus qhia. Txhawm rau muab qhov tshwj xeeb, hauv qab thiab sab saum toj offset tsuas yog muab ib qho khoom offset: { top: 10 } lossis offset: { top: 10, bottom: 5 } . Siv ib txoj haujlwm thaum koj xav tau dynamically xam qhov offset. |
phiaj | xaiv | node | jQuery element | qhov window khoom |
Qhia meej lub hom phiaj ntawm affix. |
.affix(options)
Qhib koj cov ntsiab lus raws li cov ntsiab lus affixed. Txais ib qho kev xaiv xaiv object
.
.affix('checkPosition')
Recalculates lub xeev ntawm affix raws li qhov ntev, txoj hauj lwm, thiab scroll txoj hauj lwm ntawm cov ntsiab lus. Cov .affix
, .affix-top
, thiab .affix-bottom
cov chav kawm ntxiv rau lossis tshem tawm ntawm cov ntsiab lus affixed raws li lub xeev tshiab. Txoj kev no yuav tsum tau hu thaum twg qhov ntev ntawm cov ntsiab lus affixed los yog lub hom phiaj lub ntsiab yog hloov, kom paub meej qhov chaw ntawm cov ntsiab lus affixed.
Bootstrap's affix plugin nthuav tawm ob peb txheej xwm rau hooking rau hauv affix functionality.
Hom xwm txheej | Kev piav qhia |
---|---|
affix.bs.affix ib | Qhov kev tshwm sim no hluav taws kub tam sim ntawd ua ntej lub caij tau affixed. |
affixed.bs.affix ua | Qhov kev tshwm sim no raug rho tawm haujlwm tom qab lub caij tau raug affixed. |
affix-top.bs.affix | Qhov kev tshwm sim no hluav taws kub tam sim ntawd ua ntej lub caij tau affixed-sab saum toj. |
affixed-top.bs.affix | Qhov kev tshwm sim no raug rho tawm haujlwm tom qab lub caij tau affixed-sab saum toj. |
affix-bottom.bs.affix ib | Qhov kev tshwm sim no hluav taws kub tam sim ntawd ua ntej lub caij tau affixed-hauv qab. |
affixed-bottom.bs.affix | Qhov kev tshwm sim no raug rho tawm haujlwm tom qab lub caij tau affixed-hauv qab. |