Javascript fun Bootstrap

Mu awọn paati Bootstrap wa si igbesi aye — ni bayi pẹlu awọn afikun jQuery aṣa 12.

Awọn awoṣe

Iṣatunṣe, ṣugbọn rọ, mu ohun itanna modal JavaScript ti aṣa pẹlu iṣẹ ṣiṣe ti o kere julọ ti o nilo ati awọn aseku ọlọgbọn.

Awọn idasile

Ṣafikun awọn akojọ aṣayan silẹ si fere ohunkohun ni Bootstrap pẹlu itanna ti o rọrun yii. Bootstrap ni atilẹyin akojọ aṣayan silẹ ni kikun lori navbar, awọn taabu, ati awọn oogun.

Scrollspy

Lo scrollspy lati ṣe imudojuiwọn awọn ọna asopọ ni navbar rẹ laifọwọyi lati ṣafihan ọna asopọ lọwọlọwọ ti o da lori ipo yi lọ.

Toggleble awọn taabu

Lo ohun itanna yii lati jẹ ki awọn taabu ati awọn oogun wulo diẹ sii nipa gbigba wọn laaye lati yi lọ nipasẹ awọn pane tabbable ti akoonu agbegbe.

Awọn imọran irinṣẹ

Gbigba tuntun lori jQuery Tipsy itanna, Awọn ohun elo irinṣẹ ko gbẹkẹle awọn aworan — wọn lo CSS3 fun awọn ohun idanilaraya ati awọn abuda data fun ibi ipamọ akọle agbegbe.

Awọn agbejade *

Ṣafikun awọn agbekọja kekere ti akoonu, bii awọn ti o wa lori iPad, si eyikeyi ipin fun alaye Atẹle ile.

* Nilo Awọn imọran irinṣẹ lati wa pẹlu

Awọn ifiranṣẹ itaniji

Ohun itanna gbigbọn jẹ kilasi kekere fun fifi iṣẹ ṣiṣe to sunmọ si awọn titaniji.

Awọn bọtini

Ṣe diẹ sii pẹlu awọn bọtini. Awọn ipinlẹ bọtini iṣakoso tabi ṣẹda awọn ẹgbẹ ti awọn bọtini fun awọn paati diẹ sii bi awọn ọpa irinṣẹ.

Subu

Gba awọn aza ipilẹ ati atilẹyin to rọ fun awọn paati ikojọpọ bi accordions ati lilọ kiri.

Carousel

Ṣẹda ariya-go-yika ti eyikeyi akoonu ti o fẹ lati pese ohun ibanisọrọ agbelera akoonu.

Iru ori

Ipilẹ kan, ohun itanna ti o gbooro ni irọrun fun ṣiṣẹda ni iyara awọn oriṣi ti o wuyi pẹlu titẹ ọrọ fọọmu eyikeyi.

Awọn iyipada *

Fun awọn ipa iyipada ti o rọrun, pẹlu bootstrap-transition.js lẹẹkan lati rọra ni awọn modals tabi ipare awọn titaniji.

* Ti beere fun iwara ni awọn afikun

Efeti sile! Gbogbo awọn afikun JavaScript nilo ẹya tuntun ti jQuery.

Nipa awọn awoṣe

Iṣatunṣe, ṣugbọn rọ, mu ohun itanna modal JavaScript ti aṣa pẹlu iṣẹ ṣiṣe ti o kere julọ ti o nilo ati awọn aseku ọlọgbọn.

Ṣe igbasilẹ faili

Apẹẹrẹ aimi

Ni isalẹ jẹ modal ti a ṣe ni iṣiro.

Live demo

Yi modal pada nipasẹ JavaScript nipa titẹ bọtini ni isalẹ. Yoo rọra si isalẹ ati ipare ni lati oke ti oju-iwe naa.

Ifilọlẹ demo modal

Lilo bootstrap-modal

Pe modal nipasẹ JavaScript:

  1. $ ( '#myModal' ). modal ( awọn aṣayan )

Awọn aṣayan

Oruko iru aiyipada apejuwe
sile boolian ooto Pẹlu a modal-backdrop ano. Ni omiiran, pato staticfun ẹhin ẹhin eyiti ko pa modal naa ni titẹ.
keyboard boolian ooto Tilekun modal nigbati o ba tẹ bọtini ona abayo
ifihan boolian ooto Ṣe afihan modal nigbati o bẹrẹ.

Siṣamisi

O le mu awọn modals ṣiṣẹ lori oju-iwe rẹ ni irọrun laisi nini lati kọ laini kan ti JavaScript. O kan ṣeto data-toggle="modal"lori eroja oludari pẹlu kan data-target="#foo"tabi href="#foo"eyiti o ni ibamu si id ano modal, ati nigbati o ba tẹ, yoo ṣe ifilọlẹ modal rẹ.

Paapaa, lati ṣafikun awọn aṣayan si apẹẹrẹ modal rẹ, kan ṣafikun wọn bi awọn abuda data afikun lori boya ipin iṣakoso tabi isamisi modal funrararẹ.

  1. <a class = "btn" data-toggle = "modal" href = "#myModal" > Ilana ifilọlẹ </a>
  1. <div class = "modal hide" id = "myModal" >
  2. <div kilasi = "modal-akọsori" >
  3. <bọtini iru = "bọtini" kilasi = "sunmọ" data-dismiss = "modal" > × </bọtini>
  4. <h3> Akọsori awoṣe </h3>
  5. </div>
  6. <div class = "modal-body" >
  7. <p> Ara kan ti o dara… </p>
  8. </div>
  9. <div class = "modal-footer" >
  10. <a href = "#" kilasi = "btn" data-dismiss = "modal" > Pade </a>
  11. <a href = "#" kilasi = "btn btn-primary" > Fipamọ awọn ayipada </a>
  12. </div>
  13. </div>
Efeti sile! Ti o ba fẹ modal rẹ lati ṣe ere sinu ati ita, kan ṣafikun .fadekilasi kan si .modalipin (tọkasi demo lati rii eyi ni iṣe) ati pẹlu bootstrap-transition.js.

Awọn ọna

.modal(awọn aṣayan)

Mu akoonu rẹ ṣiṣẹ bi modal. Gba awọn aṣayan iyan object.

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

.modal('yí')

Pẹlu ọwọ yipada modal kan.

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

.modal('ifihan')

Pẹlu ọwọ ṣii modal kan.

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

.modal('tọju')

Pẹlu ọwọ hides a modal.

  1. $ ( '#myModal' ). modal ( 'tọju' )

Awọn iṣẹlẹ

Kilasi modal Bootstrap ṣafihan awọn iṣẹlẹ diẹ fun sisọ sinu iṣẹ ṣiṣe modal.

Iṣẹlẹ Apejuwe
ifihan Yi iṣẹlẹ ina lẹsẹkẹsẹ nigbati awọn showapẹẹrẹ ọna ti a npe ni.
han Iṣẹlẹ yii jẹ ina nigbati modal ti jẹ ki o han si olumulo (yoo duro fun awọn iyipada css lati pari).
tọju Iṣẹlẹ yii jẹ ina lẹsẹkẹsẹ nigbati ọna hideapẹẹrẹ ti pe.
farasin Iṣẹlẹ yii jẹ ina nigbati modal naa ba ti pari fifipamọ lati ọdọ olumulo (yoo duro fun awọn iyipada css lati pari).
  1. $ ( '#myModal' ). lori ( 'farasin' , iṣẹ () {
  2. // se nkan…
  3. })

Ohun itanna ScrollSpy jẹ fun mimu dojuiwọn awọn ibi-afẹde nav laifọwọyi da lori ipo yi lọ.

Ṣe igbasilẹ faili

Apeere navbar pẹlu scrollspy

Yi lọ si agbegbe ni isalẹ ki o wo imudojuiwọn lilọ kiri. Awọn nkan isọ silẹ yoo jẹ afihan bi daradara. Danwo!

@sanra

Ad leggings keytar, brunch id art party dolor labour. Pitchfork yr enim lo-fi kí wọn tó ta qui. Tumblr oko-to-tabili awọn ẹtọ keke ohunkohun ti. Animu keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby siweta lomo Jean shorts, Williamsburg hoodie minim qui o jasi ko ti gbọ ti wọn et cardigan Trust fund culpa biodiesel wes anderson aesthetic. Nihi tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.

@mdo

Veniam marfa mustache skateboard, adipisicing fugiat velit pitchfork irungbọn. Freegan irungbọn aliqua cupidatat mcsweeney ká vero. Cupidatat mẹrin loko nisi, ea helvetica nulla carles. Tatuu cosby siweta ounje ikoledanu, mcsweeney ká quis ti kii freegan fainali. Lo-fi wes anderson +1 sartorial. Carles ti kii ṣe adaṣe darapupo quis gentrify. Brooklyn adipisicing ọnà ọti igbakeji keytar deserunt.

ọkan

Occaecat commodo aliqua delectus. Fap iṣẹ ọti deserunt skateboard ea. Lomo keke awọn ẹtọ adipisicing banh mi, velit ea sunt next level locavore nikan-origin kofi in magna veniam. Giga aye id fainali, iwoyi o duro si ibikan consequat quis aliquip banh mi pitchfork. Vero VHS est adipisicing. Consectetur nisi DIY minim ojiṣẹ apo. cred ex in, alagbero delectus consectetur fanny pack ipad.

meji

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 bulọọgi, culpa ojiṣẹ apo marfa ohunkohun ti delectus ounje ikoledanu. Sapiente synth id assumenda. Locavore sed helvetica cliche irony, thundercats o jasi ko tii gbọ ti wọn consequat hoodie gluten-free lo-fi fap aliquip. Labore elit placeat ṣaaju ki wọn to ta, Terry Richardson proident brunch nesciunt quis cosby siweta pariatur keffiyeh ut helvetica artisan. Cardigan iṣẹ ọti seitan readymade velit. VHS chambray laboris tempor veniam. Animu mollit minim commodo ullamco thundercats.


Lilo bootstrap-scrollspy.js

Pe scrollspy nipasẹ JavaScript:

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

Siṣamisi

Lati fi awọn iṣọrọ scrollspy ihuwasi si rẹ topbar lilọ, o kan fi data-spy="scroll"si awọn ano ti o fẹ lati ṣe amí lori (julọ ojo melo yi yoo jẹ awọn ara).

  1. <body data-spy = "yi lọ" > ... </body>
Efeti sile! Awọn ọna asopọ Navbar gbọdọ ni awọn ibi-afẹde id ti o yanju. Fun apẹẹrẹ, a <a href="#home">home</a>gbọdọ ba nkan ṣe ni dom bi <div id="home"></div>.

Awọn ọna

.scrollspy('itura')

Nigbati o ba nlo scrollspy ni apapo pẹlu fifi kun tabi yiyọ awọn eroja kuro lati DOM, iwọ yoo nilo lati pe ọna isọdọtun bii bẹ:

  1. $ ( '[data-spy="yilọ" ). kọọkan ( iṣẹ () {
  2. var $ amí = $ ( eyi ). scrollspy ( 'itura' )
  3. });

Awọn aṣayan

Oruko iru aiyipada apejuwe
aiṣedeede nọmba 10 Awọn piksẹli lati aiṣedeede lati oke nigbati o ṣe iṣiro ipo ti yi lọ.

Awọn iṣẹlẹ

Iṣẹlẹ Apejuwe
mu ṣiṣẹ Iṣẹlẹ yii n ṣiṣẹ nigbakugba ti ohun kan ba muu ṣiṣẹ nipasẹ scrollspy.

Ohun itanna yii ṣe afikun iyara, taabu ti o ni agbara ati iṣẹ ṣiṣe egbogi fun iyipada nipasẹ akoonu agbegbe.

Ṣe igbasilẹ faili

Awọn taabu apẹẹrẹ

Tẹ awọn taabu ti o wa ni isalẹ lati yi laarin awọn pane ti o farapamọ, paapaa nipasẹ awọn akojọ aṣayan silẹ.

Aise Denimu o jasi ko ti gbọ ti wọn Jean shorts Austin. Nesciunt tofu stumptown aliqua, Retiro synth titunto si wẹ. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum ipad. Seitan aliquip quis cardigan American aso, butcher voluptate nisi qui.

Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.


Lilo bootstrap-tab.js

Mu awọn taabu taabu ṣiṣẹ nipasẹ JavaScript (taabu kọọkan nilo lati muu ṣiṣẹ ni ẹyọkan):

  1. $ ( '#myTab a' ). tẹ ( iṣẹ ( e ) {
  2. e . idilọwọ Aiyipada ();
  3. $ ( eyi ). taabu ( 'ifihan' );
  4. })

O le mu awọn taabu kọọkan ṣiṣẹ ni awọn ọna pupọ:

  1. $ ( '#myTab a[href="#profaili"]' ). taabu ( 'ifihan' ); // Yan taabu nipa orukọ
  2. $ ( '#myTab a: akọkọ' ). taabu ( 'ifihan' ); // Yan taabu akọkọ
  3. $ ( '#myTab a: kẹhin' ). taabu ( 'ifihan' ); // Yan kẹhin taabu
  4. $ ( '#myTab li: eq(2) a' ). taabu ( 'ifihan' ); // Yan taabu kẹta (0-itọkasi)

Siṣamisi

O le mu taabu kan ṣiṣẹ tabi lilọ kiri egbogi laisi kikọ eyikeyi JavaScript nipa sisọ pato data-toggle="tab"tabi data-toggle="pill"lori eroja kan. Ṣafikun navati nav-tabsawọn kilasi si taabu ulyoo lo iselona taabu bootstrap.

  1. <ul kilasi = "nav nav-tabs" >
  2. <li><a href = "#home" data-toggle = "taabu" > Ile </a></li>
  3. <li><a href = "#profile" data-toggle = "taabu" > Profaili </a></li>
  4. <li><a href = "#messages" data-toggle = "taabu" > Awọn ifiranṣẹ </a></li>
  5. <li><a href = "#settings" data-toggle = "taabu" > Eto </a></li>
  6. </ul>

Awọn ọna

$().taabu

Mu eroja taabu ṣiṣẹ ati eiyan akoonu. Taabu yẹ ki o ni boya a data-targettabi hrefifọkansi oju ipade apoti kan ninu DOM.

  1. <ul kilasi = "nav nav-tabs" id = "myTab" >
  2. <li class = "lọwọ" ><a href = "#ile" > Ile </a></li>
  3. <li > <a href = "#profaili"> Profaili </a></li>
  4. <li><a href = "#messages" > Awọn ifiranṣẹ </a></li>
  5. <li><a href = "#eto" > Eto </a></li>
  6. </ul>
  7.  
  8. <div class = "akoonu-taabu" >
  9. <div class = "tab-pane active" id = "ile" > ... </div>
  10. <div class = "tab-pane" id = "profaili" > ... </div>
  11. <div class = "tab-pane" id = "awọn ifiranṣẹ" > ... </div>
  12. <div class = "tab-pane" id = "awọn eto" > ... </div>
  13. </div>
  14.  
  15. <akosile>
  16. $ ( iṣẹ () {
  17. $ ( '#myTab a: kẹhin' ). taabu ( 'ifihan' );
  18. })
  19. </script>

Awọn iṣẹlẹ

Iṣẹlẹ Apejuwe
ifihan Iṣẹlẹ yii ina lori ifihan taabu, ṣugbọn ṣaaju ki o to han taabu tuntun. Lo event.targetati event.relatedTargetlati fojusi taabu ti nṣiṣe lọwọ ati taabu lọwọlọwọ ti tẹlẹ (ti o ba wa) lẹsẹsẹ.
han Iṣẹlẹ yi ina lori ifihan taabu lẹhin ti a ti fi taabu kan han. Lo event.targetati event.relatedTargetlati fojusi taabu ti nṣiṣe lọwọ ati taabu lọwọlọwọ ti tẹlẹ (ti o ba wa) lẹsẹsẹ.
  1. $ ( 'a[data-toggle = "taabu"]' ). lori ( 'fi han' , iṣẹ ( e ) {
  2. e . afojusun // mu ṣiṣẹ taabu
  3. e . jẹmọTarget // ti tẹlẹ taabu
  4. })

About Tooltips

Atilẹyin nipasẹ ohun itanna jQuery.tipsy ti o dara julọ ti a kọ nipasẹ Jason Frame; Awọn imọran irinṣẹ jẹ ẹya imudojuiwọn, eyiti ko gbẹkẹle awọn aworan, lo css3 fun awọn ohun idanilaraya, ati awọn abuda data fun ibi ipamọ akọle agbegbe.

Ṣe igbasilẹ faili

Apeere lilo awọn Italolobo Irinṣẹ

Raba lori awọn ọna asopọ ni isalẹ lati wo awọn imọran irinṣẹ:

Awọn sokoto to gun ni ipele keji keffiyeh o ṣee ṣe ko tii gbọ ti wọn. Photo agọ irungbọn aise Denimu letterpress ajewebe ojiṣẹ apo stumptown. Farm-to-tabili seitan, mcsweeney's fixie alagbero quinoa 8-bit American aṣọ ni Terry Richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, mẹrin loko mcsweeney ká cleanse vegan chambray. A gan ironic artisan whatever keytar , scenester farm-to-table banksy Austin twitter handle freegan cred raw Denimu nikan-Oti kofi gbogun ti.


Lilo bootstrap-tooltip.js

Ṣe okunfa ohun elo irinṣẹ nipasẹ JavaScript:

  1. $ ( '#apẹẹrẹ' ). ohun elo ( awọn aṣayan )

Awọn aṣayan

Oruko iru aiyipada apejuwe
iwara boolian ooto lo iyipada css ipare si ọpa irinṣẹ
ipo okun | iṣẹ 'oke' bi o si ipo awọn Tooltip - oke | isalẹ | osi | ọtun
yiyan okun eke Ti o ba ti pese oluyan, awọn ohun elo irinṣẹ yoo jẹ aṣoju si awọn ibi-afẹde pàtó.
akọle okun | iṣẹ '' iye akọle aiyipada ti tag `akọle` ko ba si
okunfa okun 'rababa' bi o ti wa ni jeki irinṣẹ - rababa | idojukọ | Afowoyi
idaduro nọmba | nkan 0

idaduro fifihan ati fifipamọ awọn ọpa irinṣẹ (ms) - ko kan si iru okunfa afọwọṣe

Ti nọmba kan ba pese, idaduro jẹ lilo si tọju/fihan mejeeji

Eto nkan jẹ:delay: { show: 500, hide: 100 }

Efeti sile! Awọn aṣayan fun awọn itọnisọna irinṣẹ kọọkan le jẹ iyasọtọ nipasẹ lilo awọn abuda data.

Siṣamisi

Fun awọn idi iṣẹ ṣiṣe, Ohun elo irinṣẹ ati Agbejade data-apis n wọle. Ti o ba fẹ lati lo wọn kan pato aṣayan yiyan.

  1. <a href = "#" rel = "tooltip" akọle = "irinṣẹ irinṣẹ akọkọ" > rababa lori mi </a>

Awọn ọna

$() ohun elo (awọn aṣayan)

So oluṣakoso ohun elo irinṣẹ si ikojọpọ eroja.

.tooltip('ifihan')

Ṣe afihan ohun elo irinṣẹ eroja kan.

  1. $ ( '# ano' ). ọpa irinṣẹ ( 'ifihan' )

.tooltip('tọju')

Ìbòmọlẹ ohun ano ká irinṣẹ.

  1. $ ( '# ano' ). ọpa irinṣẹ ( 'tọju' )

.tooltip('yí')

Yipada ohun elo itọsi irinṣẹ.

  1. $ ( '# ano' ). ọpa irinṣẹ ( 'bayi' )

Nipa popovers

Ṣafikun awọn agbekọja kekere ti akoonu, bii awọn ti o wa lori iPad, si eyikeyi ipin fun alaye Atẹle ile.

* Nilo Italolobo Irinṣẹ lati wa pẹlu

Ṣe igbasilẹ faili

Apeere rababa popover

Raba lori bọtini lati ma nfa popover naa.


Lilo bootstrap-popover.js

Mu popovers ṣiṣẹ nipasẹ JavaScript:

  1. $ ( '#apẹẹrẹ' ). popover ( awọn aṣayan )

Awọn aṣayan

Oruko iru aiyipada apejuwe
iwara boolian ooto lo iyipada css ipare si ọpa irinṣẹ
ipo okun | iṣẹ 'ọtun' bi o si ipo awọn popover - oke | isalẹ | osi | ọtun
yiyan okun eke ti o ba ti pese oluyanju, awọn ohun elo irinṣẹ yoo jẹ aṣoju si awọn ibi-afẹde ti a pato
okunfa okun 'rababa' bi o ti wa ni jeki irinṣẹ - rababa | idojukọ | Afowoyi
akọle okun | iṣẹ '' iye akọle aiyipada ti o ba jẹ pe ẹya 'akọle' ko si
akoonu okun | iṣẹ '' iye akoonu aiyipada ti ‘akoonu-data’ abuda ko ba si
idaduro nọmba | nkan 0

idaduro ifihan ati fifipamo popover (ms) - ko kan si iru okunfa afọwọṣe

Ti nọmba kan ba pese, idaduro jẹ lilo si tọju/fihan mejeeji

Eto nkan jẹ:delay: { show: 500, hide: 100 }

Efeti sile! Awọn aṣayan fun awọn agbejade kọọkan le jẹ iyasọtọ nipasẹ lilo awọn abuda data.

Siṣamisi

Fun awọn idi iṣẹ ṣiṣe, Ohun elo irinṣẹ ati Agbejade data-apis n wọle. Ti o ba fẹ lati lo wọn kan pato aṣayan yiyan.

Awọn ọna

$().popover(awọn aṣayan)

Initializes popovers fun ohun akojọpọ eroja.

.popover('ifihan')

Ṣe afihan awọn eroja popover.

  1. $ ( '# ano' ). popover ( 'ifihan' )

.popover('tọju')

Ìbòmọlẹ ohun eroja popover.

  1. $ ( '# ano' ). popover ( 'tọju' )

.popover('toggle')

Yipada awọn eroja agbejade.

  1. $ ( '# ano' ). popover ( 'yii' )

Nipa titaniji

Ohun itanna gbigbọn jẹ kilasi kekere fun fifi iṣẹ ṣiṣe to sunmọ si awọn titaniji.

Gba lati ayelujara

Awọn itaniji apẹẹrẹ

Ohun itanna titaniji ṣiṣẹ lori awọn ifiranṣẹ itaniji deede, ati dina awọn ifiranṣẹ.

Guacamole mimọ! Ṣayẹwo ara ẹni ti o dara julọ, iwọ ko dara ju.

Oh imolara! O ni aṣiṣe!

Yi eyi ati iyẹn pada ki o tun gbiyanju lẹẹkansi. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.

Gbe igbese yii Tabi ṣe eyi


Lilo bootstrap-alert.js

Jeki yiyọ kuro ti itaniji nipasẹ JavaScript:

  1. $ ( "titaniji" ). gbigbọn ()

Siṣamisi

Kan ṣafikun data-dismiss="alert"si bọtini isunmọ rẹ lati funni ni iṣẹ ṣiṣe isunmọ titaniji laifọwọyi.

  1. <a class = "sunmọ" data-dismiss = "titaniji" href = "#" > & igba; </a>

Awọn ọna

$() titaniji()

Murasilẹ gbogbo awọn titaniji pẹlu iṣẹ ṣiṣe to sunmọ. Lati jẹ ki awọn titaniji rẹ gbe jade nigba pipade, rii daju pe wọn ni .fadeati .inkilasi ti lo tẹlẹ si wọn.

.titaniji('sunmọ')

Tilekun itaniji.

  1. $ ( "titaniji" ). Itaniji ( 'sunmọ' )

Awọn iṣẹlẹ

Kilasi gbigbọn Bootstrap ṣafihan awọn iṣẹlẹ diẹ fun sisọ sinu iṣẹ ṣiṣe titaniji.

Iṣẹlẹ Apejuwe
sunmo Yi iṣẹlẹ ina lẹsẹkẹsẹ nigbati awọn closeapẹẹrẹ ọna ti a npe ni.
ni pipade Iṣẹlẹ yii jẹ ina nigbati itaniji ti wa ni pipade (yoo duro fun awọn iyipada css lati pari).
  1. $ ( '#mi-ititaniji' ). ( 'ni pipade' , iṣẹ () {
  2. // se nkan…
  3. })

Nipa

Ṣe diẹ sii pẹlu awọn bọtini. Awọn ipinlẹ bọtini iṣakoso tabi ṣẹda awọn ẹgbẹ ti awọn bọtini fun awọn paati diẹ sii bi awọn ọpa irinṣẹ.

Ṣe igbasilẹ faili

Awọn lilo apẹẹrẹ

Lo awọn bọtini itanna fun awọn ipinlẹ ati awọn iyipada.

Stateful
Yiyi ẹyọkan
Apoti ayẹwo
Redio

Lilo bootstrap-button.js

Mu awọn bọtini ṣiṣẹ nipasẹ JavaScript:

  1. $ ( '.nav-tabs' ). bọtini ()

Siṣamisi

Awọn abuda data jẹ pataki si ohun itanna bọtini. Ṣayẹwo koodu apẹẹrẹ ni isalẹ fun awọn oriṣi isamisi oriṣiriṣi.

  1. <!-- Ṣafikun data-toggle="bọtini" lati mu toggling ṣiṣẹ lori bọtini ẹyọkan -->
  2. <bọtini kilasi = "btn" data-toggle = "bọtini" > Yiyi Nikan </button>
  3.  
  4. <!-- Ṣafikun data-toggle="buttons-checkbox" fun aṣa aṣayẹwo apoti lori btn-group -->
  5. <div class = "btn-group" data-toggle = "bọtini-checkbox" >
  6. <bọtini kilasi = "btn" > Osi </bọtini>
  7. <bọtini kilasi = "btn" > Aarin </bọtini>
  8. <bọtini kilasi = "btn" > Ọtun </bọtini>
  9. </div>
  10.  
  11. <!-- Ṣafikun data-toggle="buttons-radio" fun aṣa aṣa redio lori btn-ẹgbẹ -->
  12. <div class = "btn-group" data-toggle = "awọn bọtini-redio" >
  13. <bọtini kilasi = "btn" > Osi </bọtini>
  14. <bọtini kilasi = "btn" > Aarin </bọtini>
  15. <bọtini kilasi = "btn" > Ọtun </bọtini>
  16. </div>

Awọn ọna

$()bọtini ('yipo')

Toggles titari ipinle. Yoo fun bọtini naa hihan ti o ti muu ṣiṣẹ.

Efeti sile! O le mu yiyi pada laifọwọyi ti bọtini kan nipa lilo data-toggleabuda naa.
  1. <bọtini kilasi = "btn" data-toggle = "bọtini" > </bọtini>

$().bọtini('ikojọpọ')

Ṣeto ipo bọtini si ikojọpọ - mu bọtini ṣiṣẹ ati yi ọrọ pada si ọrọ ikojọpọ. Ọrọ ikojọpọ yẹ ki o ṣalaye lori bọtini bọtini ni lilo abuda data data-loading-text.

  1. <button class = "btn" data-loading-text = "ikojọpọ nkan..." > ... </button>
Efeti sile! Firefox n tẹsiwaju ni ipo alaabo kọja awọn ẹru oju-iwe . Ilana fun eyi ni lati lo autocomplete="off".

$().bọtini('tunto')

Tun ipo bọtini atunto - yi ọrọ pada si ọrọ atilẹba.

$().bọtini (okun)

Tun ipo bọtini atunto - yi ọrọ pada si eyikeyi ipo ọrọ asọye data.

  1. <button class = "btn" data-complete-text = "pari!" > ... </bọtini>
  2. <akosile>
  3. $ ( '.btn' ). bọtini ( 'pari' )
  4. </script>

Nipa

Gba awọn aza ipilẹ ati atilẹyin to rọ fun awọn paati ikojọpọ bi accordions ati lilọ kiri.

Ṣe igbasilẹ faili

* Nilo ohun itanna Awọn iyipada lati wa pẹlu.

Accordion apẹẹrẹ

Lilo ohun itanna idapọ, a kọ ẹrọ ailorukọ ara accordion ti o rọrun:

Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus Terry Richardson ad squid. 3 Ikooko oṣupa officia aute, ti kii cupidatat skateboard dolor brunch. Ounjẹ ikoledanu quinoa nesciunt laborum eiusmod. Brunch 3 Ikooko oṣupa tempor, sunt aliqua fi kan eye lori o squid nikan-Oti kofi nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft ọti labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher igbakeji lomo. Leggings occaecat iṣẹ ọti oko-to-tabili, aise Denimu darapupo synth nesciunt o jasi ti ko ba ti gbọ ti wọn accusamus laala alagbero VHS.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus Terry Richardson ad squid. 3 Ikooko oṣupa officia aute, ti kii cupidatat skateboard dolor brunch. Ounjẹ ikoledanu quinoa nesciunt laborum eiusmod. Brunch 3 Ikooko oṣupa tempor, sunt aliqua fi kan eye lori o squid nikan-Oti kofi nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft ọti labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher igbakeji lomo. Leggings occaecat iṣẹ ọti oko-to-tabili, aise Denimu darapupo synth nesciunt o jasi ti ko ba ti gbọ ti wọn accusamus laala alagbero VHS.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus Terry Richardson ad squid. 3 Ikooko oṣupa officia aute, ti kii cupidatat skateboard dolor brunch. Ounjẹ ikoledanu quinoa nesciunt laborum eiusmod. Brunch 3 Ikooko oṣupa tempor, sunt aliqua fi kan eye lori o squid nikan-Oti kofi nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft ọti labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher igbakeji lomo. Leggings occaecat iṣẹ ọti oko-to-tabili, aise Denimu darapupo synth nesciunt o jasi ti ko ba ti gbọ ti wọn accusamus laala alagbero VHS.

Lilo bootstrap-collapse.js

Mu ṣiṣẹ nipasẹ JavaScript:

  1. $ ( ".collapse" ). ṣubu ()

Awọn aṣayan

Oruko iru aiyipada apejuwe
obi yiyan eke Ti o ba yan lẹhinna gbogbo awọn eroja ti o le kojọpọ labẹ obi ti a ti sọ ni yoo wa ni pipade nigbati ohun kan ti o le kọlu ba han. (bii iru iwa accordion ibile)
yipada boolian ooto Yipada eroja ti o le kolu lori ẹbẹ

Siṣamisi

Kan ṣafikun data-toggle="collapse"ati ipin data-targetkan lati fi iṣakoso laifọwọyi ti nkan kan ti o le kọlu. Ẹya naa data-targetgba oluyan css kan lati lo iṣubu si. Rii daju lati ṣafikun kilasi collapsenaa si nkan ti o le ṣubu. Ti o ba fẹ ki o ṣii aiyipada, ṣafikun afikun kilasi in.

  1. <button class = "btn btn-danger" data-toggle = "collapse" data-target = "#demo" >
  2. o rọrun collapsible
  3. </bọtini>
  4.  
  5. <div id = "demo" kilasi = "kolula sinu" > </div>
Efeti sile! Lati ṣafikun iṣakoso ẹgbẹ bi accordion si iṣakoso ikojọpọ, ṣafikun abuda data naa data-parent="#selector". Tọkasi demo lati wo eyi ni iṣe.

Awọn ọna

.collapse(awọn aṣayan)

Mu akoonu rẹ ṣiṣẹ bi eroja ti o le kolu. Gba awọn aṣayan iyan object.

  1. $ ( '#myCollapsible' ). ṣubu ({
  2. toggle : iro
  3. })

.kolapse('yii')

Yipada eroja ti o le kolu lati ṣafihan tabi pamọ.

.kolapse('ifihan')

Ṣe afihan eroja ti o le ṣubu.

.kolapse('tọju')

Ìbòmọlẹ ohun kan collapsible.

Awọn iṣẹlẹ

Kilasi Collapse Bootstrap ṣafihan awọn iṣẹlẹ diẹ fun sisọ sinu iṣẹ ṣiṣe iṣubu.

Iṣẹlẹ Apejuwe
ifihan Yi iṣẹlẹ ina lẹsẹkẹsẹ nigbati awọn showapẹẹrẹ ọna ti a npe ni.
han Iṣẹlẹ yii jẹ ina nigba ti a ti jẹ ki nkan idaruku kan han si olumulo (yoo duro fun awọn iyipada css lati pari).
tọju Yi iṣẹlẹ ti wa ni kuro lenu ise lẹsẹkẹsẹ nigbati awọn hideọna ti a ti a npe ni.
farasin Iṣẹlẹ yii jẹ ina nigba ti ohun elo iṣubu kan ti farapamọ lati ọdọ olumulo (yoo duro fun awọn iyipada css lati pari).
  1. $ ( '#myCollapsible' ). lori ( 'farasin' , iṣẹ () {
  2. // se nkan…
  3. })

Nipa

Ipilẹ kan, ohun itanna ti o gbooro ni irọrun fun ṣiṣẹda ni iyara awọn oriṣi ti o wuyi pẹlu titẹ ọrọ fọọmu eyikeyi.

Ṣe igbasilẹ faili

Apeere

Bẹrẹ titẹ ni aaye ti o wa ni isalẹ lati fi awọn abajade iruwe han.


Lilo bootstrap-typeahead.js

Pe typeahead nipasẹ JavaScript:

  1. $ ( '.typehead' ). oriṣi ori ()

Awọn aṣayan

Oruko iru aiyipada apejuwe
orisun orun [] Orisun data lati beere lodi si.
awọn ohun kan nọmba 8 Nọmba ti o pọju awọn ohun kan lati ṣafihan ninu sisọ silẹ.
baramu iṣẹ irú insensitive Ọna ti a lo lati pinnu boya ibeere kan ba nkan kan mu. Gba ariyanjiyan ẹyọkan, itemlodi si eyiti lati ṣe idanwo ibeere naa. Wọle si ibeere lọwọlọwọ pẹlu this.query. Da boolean pada trueti ibeere ba jẹ baramu.
lẹsẹsẹ iṣẹ baramu gangan,
ọran ifarabalẹ,
ọran aibikita
Ọna ti a lo lati to awọn abajade pipe laifọwọyi. Gba ariyanjiyan ẹyọkan itemsati pe o ni aaye ti apẹẹrẹ iruhead. Tọkasi ibeere lọwọlọwọ pẹlu this.query.
afihan iṣẹ ṣe afihan gbogbo awọn ibaamu aiyipada Ọna ti a lo lati ṣe afihan awọn abajade adaṣe. Gba ariyanjiyan ẹyọkan itemati pe o ni aaye ti apẹẹrẹ iruhead. O yẹ ki o pada html.

Siṣamisi

Ṣafikun awọn abuda data lati forukọsilẹ nkan kan pẹlu iṣẹ ṣiṣe oriṣi.

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

Awọn ọna

.typehead(awọn aṣayan)

Ti bẹrẹ titẹ sii pẹlu ori oriṣi.