JavaScript

Bweretsani zamoyo za Bootstrap - tsopano ndi mapulagini 13 a jQuery.

Munthu payekha kapena wophatikizidwa

Mapulagini amatha kuphatikizidwa payekhapayekha (ngakhale ena amafunikira kudalira), kapena zonse mwakamodzi. Ma bootstrap.js ndi bootstrap.min.js ali ndi mapulagini onse mufayilo imodzi.

Makhalidwe a data

Mutha kugwiritsa ntchito mapulagini onse a Bootstrap kudzera mu API yamakapu osalemba mzere umodzi wa JavaScript. Iyi ndiye kalasi yoyamba ya API ya Bootstrap ndipo iyenera kukhala kuganizira kwanu koyamba mukamagwiritsa ntchito pulogalamu yowonjezera.

Izi zati, nthawi zina zingakhale zofunika kuzimitsa ntchitoyi. Chifukwa chake, timaperekanso kuthekera koletsa API ya data pochotsa zochitika zonse pagulu lokhala ndi `'data-api'`. Izi zikuwoneka motere:

  1. $ ( 'thupi' ). kuzimitsa ( '.data-api' )

Kapenanso, kuti mulondole pulogalamu yowonjezera, ingophatikizani dzina la plugin ngati malo okhala ndi dzina la data-api monga chonchi:

  1. $ ( 'thupi' ). kuzimitsa ( '.alert.data-api' )

Programmatic API

Tikukhulupiriranso kuti muyenera kugwiritsa ntchito mapulagini onse a Bootstrap kudzera mu JavaScript API. Ma API onse omwe ali pagulu ndi amodzi, njira zosinthira, ndikubweza zosonkhanitsa zomwe zachitika.

  1. $ ( ".btn.danger" ). batani ( "kusintha" ). addClass ( "mafuta" )

Njira zonse ziyenera kuvomereza chinthu chosankha, chingwe chomwe chimayang'ana njira inayake, kapena palibe (chomwe chimayambitsa pulogalamu yowonjezera yokhala ndi machitidwe osakhazikika):

  1. $ ( "#myModal" ). modal () // yoyambitsidwa ndi zosasintha
  2. $ ( "#myModal" ). modal ({ kiyibodi : zabodza }) // zoyambitsidwa popanda kiyibodi
  3. $ ( "#myModal" ). modal ( 'show' ) // kuyambitsa ndi kuyitanitsa kuwonetsa nthawi yomweyo

Pulagi iliyonse imawululanso womanga wake pamtengo wa `Constructor`: $.fn.popover.Constructor. Ngati mukufuna kupeza pulogalamu yowonjezera, itengereni mwachindunji ku chinthu: $('[rel=popover]').data('popover').

Palibe Kusemphana

Nthawi zina pamafunika kugwiritsa ntchito mapulagini a Bootstrap okhala ndi ma UI ena. Pazifukwa izi, kugunda kwa mayina kumachitika nthawi zina. Izi zikachitika, mutha kuyitanitsa pulogalamu yowonjezera .noConflictyomwe mukufuna kubwezeretsanso mtengo wake.

  1. var bootstrapButton = $ . fn . batani . noConflict () // bweretsani $.fn.button ku mtengo womwe munapatsidwa kale
  2. $ . fn . bootstrapBtn = bootstrapButton // perekani $().bootstrapBtn ntchito ya bootstrap

Zochitika

Bootstrap imapereka zochitika zapadera pazochita zapadera za pulogalamu yowonjezera. Nthawi zambiri, izi zimabwera mu mawonekedwe osamalizidwa komanso am'mbuyomu - pomwe mawu osamalitsa (mwachitsanzo. show) amayambika kumayambiriro kwa chochitika, ndipo mawonekedwe ake apitawo (mwachitsanzo. shown) amayambika akamaliza kuchitapo kanthu.

Zochitika zonse zopanda malire zimapereka magwiridwe antchito a preventDefault. Izi zimapereka mwayi woyimitsa kuchita chinthu chisanayambe.

  1. $ ( '#myModal' ). pa ( 'show' , ntchito ( e ) {
  2. ngati (! data ) kubwerera e . preventDefault () // imayimitsa modal kuti isawonetsedwe
  3. })

Za kusintha

Pazosavuta kusintha, phatikizani bootstrap-transition.js kamodzi pamodzi ndi mafayilo ena a JS. Ngati mukugwiritsa ntchito compiled (kapena minified) bootstrap.js , palibe chifukwa chophatikizira izi-zilipo kale.

Gwiritsani ntchito milandu

Zitsanzo zingapo za pulogalamu yowonjezera yosinthira:

  • Kutsetsereka kapena kuzimiririka mu ma modal
  • Kutulutsa ma tabo
  • Zidziwitso zakuzirala
  • Makatani otsetsereka a carousel

Zitsanzo

Ma modals amasinthidwa, koma osinthika, ma dialog omwe ali ndi magwiridwe antchito ochepa komanso zosasintha zanzeru.

Chitsanzo chokhazikika

Mawonekedwe operekedwa okhala ndi mutu, thupi, ndi zochita m'munsimu.

  1. <div class = "modal hide fade" >
  2. <div class = "modal-header" >
  3. <button type = "button" class = "close" data-dismiss = "modal" aria-hidden = "true" > × </ batani>
  4. <h3> Mutu wamutu </h3>
  5. </div>
  6. <div class = "modal-body" >
  7. <p> Thupi limodzi labwino… </p>
  8. </div>
  9. <div class = "modal-footer" >
  10. <a href = "#" class = "btn"> Tsekani </a> _
  11. <a href = "#" class = "btn btn-primary"> Sungani zosintha </a>
  12. </div>
  13. </div>

Chiwonetsero chamoyo

Sinthani modal kudzera pa JavaScript podina batani pansipa. Idzatsika ndikuzimiririka kuchokera pamwamba pa tsamba.

  1. <!-- Batani loyambitsa modal -->
  2. <a href = "#myModal" role = "button" class = "btn" data-toggle = "modal"> Launch demo mode </a>
  3.  
  4. <!-- Modali -->
  5. <div id = "myModal" class = "modal hide fade" tabindex = "-1" role = "dialog" aria-labelledby = "myModalLabel" aria- hidden = "true" >
  6. <div class = "modal-header" >
  7. <button type = "button" class = "close" data-dismiss = "modal" aria-hidden = "zoona" > × </button>
  8. <h3 id = "myModalLabel" > Mutu wamutu </h3>
  9. </div>
  10. <div class = "modal-body" >
  11. <p> Thupi limodzi labwino… </p>
  12. </div>
  13. <div class = "modal-footer" >
  14. <button class = "btn" data-dismiss = "modal" aria-hidden = "true" > Tsekani </button>
  15. <button class = "btn btn-primary" > Sungani zosintha </ batani>
  16. </div>
  17. </div>

Kugwiritsa ntchito

Kudzera muzochita za data

Yambitsani modali osalemba JavaScript. Khazikitsani data-toggle="modal"chinthu chowongolera, ngati batani, limodzi ndi data-target="#foo"kapena href="#foo"kutsata njira inayake kuti musinthe.

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

Kudzera pa JavaScript

Imbani modal yokhala ndi id myModalyokhala ndi mzere umodzi wa JavaScript:

  1. $ ( '#myModal' ). modali ( zosankha )

Zosankha

Zosankha zitha kuperekedwa kudzera pa data kapena JavaScript. Pamawonekedwe a data, yonjezerani dzina lachisankho ku data-, monga mu data-backdrop="".

Dzina mtundu kusakhulupirika kufotokoza
kumbuyo boolean zoona Mulinso modal-backdrop element. Kapenanso, tchulani staticzakumbuyo zomwe sizitseka moduli mukadina.
kiyibodi boolean zoona Amatseka modali pamene kiyi yothawa ikanikizidwa
chiwonetsero boolean zoona Imawonetsa modali ikayambika.
kutali njira zabodza

Ngati ulalo wakutali waperekedwa, zomwe zili mkati zimayikidwa kudzera munjira ya jQuery loadndikulowetsa mu fayilo ya .modal-body. Ngati mukugwiritsa ntchito data api, mutha kugwiritsa ntchito hreftag kuti mutchule komwe kuli kutali. Chitsanzo cha izi chikuwonetsedwa pansipa:

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

Njira

.modal(zosankha)

Imayambitsa zomwe zili ngati modal. Imavomereza zomwe mungachite object.

  1. $ ( '#myModal' ). modali ({
  2. keyboard : zabodza
  3. })

.modal('kusintha')

Imatembenuza pamanja modali.

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

.modal('show')

Pamanja amatsegula modali.

  1. $ ( '#myModal' ). modali ( 'show' )

.modal('bisala')

Amabisa pamanja modali.

  1. $ ( '#myModal' ). modali ( 'hide' )

Zochitika

Kalasi ya modal ya Bootstrap imawulula zochitika zingapo kuti zigwirizane ndi machitidwe a modal.

Chochitika Kufotokozera
chiwonetsero Chochitika ichi chimayaka nthawi yomweyo shownjira yachitsanzo itayitanidwa.
zowonetsedwa Chochitikachi chimachotsedwa pomwe modal yawonetsedwa kwa wogwiritsa ntchito (idikirira kuti kusintha kwa css kumalize).
kubisa Chochitika ichi chimachotsedwa nthawi yomweyo pamene hidenjira yachitsanzo yayitanidwa.
zobisika Chochitikachi chimachotsedwa pomwe modal yatha kubisidwa kwa wogwiritsa ntchito (idikirira kuti kusintha kwa css kumalize).
  1. $ ( '#myModal' ). pa ( 'zobisika' , ntchito () {
  2. // kuchitapo kanthu...
  3. })

Chitsanzo mu navbar

Pulagi ya ScrollSpy ndi yongosintha zokha za nav kutengera malo opukutira. Sungani malo omwe ali pansi pa navbar ndikuwona kusintha kwa kalasi yogwira. Zinthu zotsikirapo zidzawonetsedwanso.

@mafuta

Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi asanagulitse. Ufulu wa njinga zamtundu wa Tumblr zilizonse. Ma cardigan opangidwa ndi manja. Chithunzi cha Velit seitan mcsweeney 3 wolf moon irure. Kabudula wa Cosby lomo wa jean, williamsburg hoodie minim qui mwina simunamvepo za iwo et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.

@mdo

Veniam marfa masharubu skateboard, adipisicing fugiat velit pitchfork ndevu. Freegan ndevu aliqua cupidatat mcsweeney's vero. Cupidatat zinayi loko nisi, ea helvetica nulla carles. Tattooed cosby sweater food truck, mcsweeney's quis non freegan vinyl. Lo-fi wes anderson +1 sartorial. Carles non aesthetic exercitation quis gentrify. Brooklyn adipisicing craft beer vice keytar deserunt.

imodzi

Occaecat commodo aliqua deelectus. Fap craft beer deserunt skateboard ea. Lomo bicycle rights adipisicing banh mi, velit ea sunt next level locavore single-origin coffee in magna veniam. High life id vinyl, echo park consequat quis aliquip banh mi pitchfork. Vero VHS ndi adipisicing. Consectetur nisi DIY minim messenger bag. Cred ex in, sustainable deelectus consectetur fanny pack iphone.

awiri

In incididunt echo park, officia deserunt mcsweeney's proident master cleanse thundercats sapiente veniam. Excepteur VHS elit, proident shoreditch +1 biodiesel laborum craft beer. Single-origin coffee wayfarers irure four loko, cupidatat terry richardson master cleanse. Assumenda you probably haven't heard of them art party fanny pack, tattooed nulla cardigan tempor ad. Proident wolf nesciunt sartorial keffiyeh eu banh mi sustainable. Elit wolf voluptate, lo-fi ea portland before they sold out four loko. Locavore enim nostrud mlkshk brooklyn nesciunt.

three

Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.

Keytar twee blog, culpa messenger bag marfa whatever delectus food truck. Sapiente synth id guessnda. Locavore sed helvetica cliche irony, mabingu mwina simunawamvepo consequat hoodie gluten-free lo-fi fap aliquip. Labore elit placeat asanagulitse, terry richardson proident brunch nesciunt quis cosby sweater pariatur keffiyeh ut helvetica artisan. Cardigan craft mowa seitan readymade velit. VHS chambray laboris tempor veniam. Anim mollit minim commodo ullamco mabingu.


Kugwiritsa ntchito

Kudzera muzochita za data

Kuti muwonjezere machitidwe a scrollspy pakuyenda kwanu kwapamwamba, ingowonjezerani data-spy="scroll"ku chinthu chomwe mukufuna kuti mukazonde (nthawi zambiri ili ndi thupi) data-target=".navbar"ndikusankha nav yoti mugwiritse ntchito. Mufuna kugwiritsa ntchito scrollspy ndi .navgawo.

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

Kudzera pa JavaScript

Imbani scrollspy kudzera pa JavaScript:

  1. $ ( '#navbar' ). scrollspy ()
Mungodziwiratu! Maulalo a Navbar akuyenera kukhala ndi ma id omwe angathetsedwe. Mwachitsanzo, <a href="#home">home</a>kuyenera kufanana ndi chinthu chomwe chili mu dome ngati <div id="home"></div>.

Njira

.scrollspy('refresh')

Mukamagwiritsa ntchito scrollspy molumikizana ndi kuwonjezera kapena kuchotsa zinthu mu DOM, muyenera kuyimbira njira yotsitsimutsa motere:

  1. $ ( '[data-spy="scroll"]' ). chilichonse ( ntchito () {
  2. var $ kazitape = $ ( izi ). scrollspy ( 'refresh' )
  3. });

Zosankha

Zosankha zitha kuperekedwa kudzera pa data kapena JavaScript. Pamawonekedwe a data, yonjezerani dzina lachisankho ku data-, monga mu data-offset="".

Dzina mtundu kusakhulupirika kufotokoza
kuchepetsa nambala 10 Ma pixel oti muyike kuchokera pamwamba powerengera malo osindikizira.

Zochitika

Chochitika Kufotokozera
yambitsa Chochitikachi chimayaka nthawi iliyonse chinthu chatsopano chikatsegulidwa ndi scrollspy.

Zitsanzo tabu

Onjezani magwiridwe antchito a tabu achangu, osinthika kuti musinthe pazigawo zazomwe zili kwanuko, ngakhale kudzera m'mindandanda yotsitsa.

denim yaiwisi mwina simunamvepo za iwo akabudula a jean Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. 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 iphone. Seitan aliquip quis cardigan American aarel, 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.


Kugwiritsa ntchito

Yambitsani ma tabable kudzera pa JavaScript (tabu iliyonse iyenera kutsegulidwa payekhapayekha):

  1. $ ( '#myTab a' ). dinani ( ntchito ( e ) {
  2. e . preventDefault ();
  3. $ ( izi ). tabu ( 'show' );
  4. })

Mutha kuyambitsa ma tabo amodzi m'njira zingapo:

  1. $ ( '#myTab a[href="#profile"]' ). tabu ( 'show' ); // Sankhani tabu ndi dzina
  2. $ ( '#myTab a:first' ). tabu ( 'show' ); // Sankhani tsamba loyamba
  3. $ ( '#myTab a:last' ). tabu ( 'show' ); // Sankhani tabu yomaliza
  4. $ ( '#myTab li:eq(2) a' ). tabu ( 'show' ); // Sankhani tabu lachitatu (0-indexed)

Markup

Mutha kuyambitsa tabu kapena kuyenda kwamapiritsi osalemba JavaScript mwa kungotchulapo data-toggle="tab"kapena data-toggle="pill"pa chinthu. Kuwonjezera navndi nav-tabsmakalasi pa tabu ulidzagwiritsa ntchito kalembedwe ka Bootstrap.

  1. <ul class = "nav-tabs" >
  2. <li><a href = "#home" data-toggle = "tab"> Kwawo </a></li >
  3. <li><a href = "#profile" data-toggle = "tab"> Mbiri </a></li >
  4. <li><a href = "#messages" data-toggle = "tab"> Mauthenga </a></li >
  5. <li><a href = "#settings" data-toggle = "tab"> Zokonda </a> </li >
  6. </ul>

Njira

$().tabu

Imayatsa chinthu cha tabu ndi chidebe cha zinthu. Tabu iyenera kukhala ndi imodzi data-targetkapena hrefyolunjika ku chidebe mu DOM.

  1. <ul class = "nav nav-tabs" id = "myTab" >
  2. <li class = "active" > <a href = "#home"> Kwawo </a></li>
  3. <li><a href = "#profile"> Mbiri </a> </li>
  4. <li><a href = "#mauthenga"> Mauthenga </a> </li>
  5. <li><a href = "#zikhazikiko"> Zokonda </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 = "mbiri" > ... </div>
  11. <div class = "tab-pane" id = "mauthenga" > ... </div>
  12. <div class = "tab-pane" id = "zikhazikiko" > ... </div>
  13. </div>
  14.  
  15. <script>
  16. $ ( ntchito () {
  17. $ ( '#myTab a:last' ). tabu ( 'show' );
  18. })
  19. </script>

Zochitika

Chochitika Kufotokozera
chiwonetsero Chochitikachi chikuyaka pa tabu chiwonetsero, koma tabu yatsopano isanasonyezedwe. Gwiritsani ntchito event.targetndikuwongolera event.relatedTargettabu yomwe ikugwira ntchito ndi tabu yogwira kale (ngati ilipo) motsatana.
zowonetsedwa Chochitika ichi chikuyaka pa tabu chiwonetsero pambuyo poti tabu yawonetsedwa. Gwiritsani ntchito event.targetndikuwongolera event.relatedTargettabu yomwe ikugwira ntchito ndi tabu yogwira kale (ngati ilipo) motsatana.
  1. $ ( 'a[data-toggle="tab"]' ). pa ( 'yawonetsedwa' , ntchito ( e ) {
  2. e . target // tabu yotsegulidwa
  3. e . zokhudzanaTarget // tabu yapita
  4. })

Zitsanzo

Kulimbikitsidwa ndi pulogalamu yowonjezera ya jQuery.tipsy yolembedwa ndi Jason Frame; Tooltips ndi mtundu wosinthidwa, womwe sudalira zithunzi, gwiritsani ntchito CSS3 pa makanema ojambula pamanja, ndi mawonekedwe a data posungira mitu yanu.

Pazifukwa zogwirira ntchito, chida ndi popover data-apis alowa, kutanthauza kuti muyenera kuziyambitsa nokha .

Yendani pamwamba pa maulalo omwe ali pansipa kuti muwone zida zothandizira:

mathalauza olimba next level keffiyeh mwina simunamvepo. Photo booth ndevu za denim yaiwisi letterpress vegan messenger bag stumptown. Zovala za Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american zovala zili ndi terry richardson vinyl chambray. Ndevu stumptown, ma cardigans banh mi lomo mabingu. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really artisan artisan whatever keytar , malo owoneka bwino a famu-to-table banksy Austin twitter handle freegan cred raw denim single-origin coffee viral.

Njira zinayi

Zothandizira m'magulu olowetsa

Mukamagwiritsa ntchito zida ndi popovers ndi magulu olowetsa a Bootstrap, muyenera kukhazikitsa container(zolembedwa pansipa) kuti mupewe zotsatira zosafunikira.


Kugwiritsa ntchito

Yambitsani chida kudzera pa JavaScript:

  1. $ ( '#chitsanzo' ). chida ( zosankha )

Zosankha

Zosankha zitha kuperekedwa kudzera pa data kapena JavaScript. Pamawonekedwe a data, yonjezerani dzina lachisankho ku data-, monga mu data-animation="".

Dzina mtundu kusakhulupirika kufotokoza
makanema ojambula boolean zoona gwiritsani ntchito kusintha kwa css ku chida
html boolean zabodza Ikani html muzothandizira. Ngati zabodza, njira ya jquery textidzagwiritsidwa ntchito kuyika zomwe zili mu dom. Gwiritsani ntchito mawu ngati mukuda nkhawa ndi kuukira kwa XSS.
kuika chingwe | ntchito 'pamwamba' momwe mungakhazikitsire chida - pamwamba | pansi | kumanzere | kulondola
wosankha chingwe zabodza Ngati chosankha chaperekedwa, zida zopangira zida zidzaperekedwa ku zomwe zafotokozedwazo.
mutu chingwe | ntchito '' mtengo wamutu wokhazikika ngati tag ya `title` palibe
choyambitsa chingwe 'hover focus' momwe chida chimayambira - dinani | kugwa | kuganizira | buku. Dziwani kuti case pass trigger mutliple, malo opatulidwa, mitundu yoyambitsa.
kuchedwa nambala | chinthu 0

kuchedwa kusonyeza ndi kubisa chida (ms) - sikugwira ntchito pamanja choyambitsa mtundu

Ngati nambala yaperekedwa, kuchedwetsa kumayikidwa pazithunzi zonse ziwiri

Kapangidwe kachinthu ndi:delay: { show: 500, hide: 100 }

chotengera chingwe | zabodza zabodza

Imawonjezera chida ku chinthu chinacontainer: 'body'

Mungodziwiratu! Zosankha za zida zapayekha zitha kufotokozedwa pogwiritsa ntchito mawonekedwe a data.

Markup

  1. <a href = "#" data-toggle = "tooltip" title = "chida choyamba"> yendani pamwamba panga </a>

Njira

$().tip(zosankha)

Imangiriza chogwirizira ku zida zosonkhanitsira.

.tooltip('show')

Imawulula zida za chinthu.

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

.tooltip('bisala')

Imabisa chida cha chinthu.

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

.tooltip('toggle')

Imatembenuza chida cha chinthu.

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

.tooltip('kuwononga')

Imabisa ndi kuwononga chida cha chinthu.

  1. $ ( '#element' ). chida ( 'destroy' )

Zitsanzo

Onjezani zophatikizika zazing'ono, monga zomwe zili pa iPad, kuzinthu zilizonse zachidziwitso chachiwiri. Yendetsani pa batani kuti muyambitse popover. Imafunikira Tooltip kuti iphatikizidwe.

Static popover

Zosankha zinayi zilipo: pamwamba, kumanja, pansi, ndi kumanzere.

Popover pamwamba

Sed posuere consectetur est at lobortis. Aenean eu lero quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Popover kumanja

Sed posuere consectetur est at lobortis. Aenean eu lero quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Popover pansi

Sed posuere consectetur est at lobortis. Aenean eu lero quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Popover adachoka

Sed posuere consectetur est at lobortis. Aenean eu lero quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Palibe zowonetsa zomwe zimawonetsedwa ngati ma popover amapangidwa kuchokera ku JavaScript ndi zomwe zili mkati datamwamalingaliro.

Chiwonetsero chamoyo

Njira zinayi


Kugwiritsa ntchito

Yambitsani popover kudzera pa JavaScript:

  1. $ ( '#chitsanzo' ). popover ( zosankha )

Zosankha

Zosankha zitha kuperekedwa kudzera pa data kapena JavaScript. Pamawonekedwe a data, yonjezerani dzina lachisankho ku data-, monga mu data-animation="".

Dzina mtundu kusakhulupirika kufotokoza
makanema ojambula boolean zoona gwiritsani ntchito kusintha kwa css ku chida
html boolean zabodza Ikani html mu popover. Ngati zabodza, njira ya jquery textidzagwiritsidwa ntchito kuyika zomwe zili mu dom. Gwiritsani ntchito mawu ngati mukuda nkhawa ndi kuukira kwa XSS.
kuika chingwe | ntchito 'chabwino' momwe mungayikitsire popover - pamwamba | pansi | kumanzere | kulondola
wosankha chingwe zabodza ngati chosankha chaperekedwa, zida zothandizira zidzaperekedwa ku zolinga zomwe zatchulidwa
choyambitsa chingwe 'dinani' momwe popover imayambira - dinani | kugwa | kuganizira | buku
mutu chingwe | ntchito '' mtengo wamutu wokhazikika ngati mawonekedwe a `mutu` palibe
zomwe zili chingwe | ntchito '' mtengo wokhazikika ngati mawonekedwe a `data-contain` palibe
kuchedwa nambala | chinthu 0

kuchedwa kusonyeza ndi kubisa popover (ms) - sikugwira ntchito pamanja choyambitsa mtundu

Ngati nambala yaperekedwa, kuchedwetsa kumayikidwa pazithunzi zonse ziwiri

Kapangidwe kachinthu ndi:delay: { show: 500, hide: 100 }

chotengera chingwe | zabodza zabodza

Imawonjezera popover ku chinthu chinacontainer: 'body'

Mungodziwiratu! Zosankha za popovers pawokha zitha kufotokozedwa mwanjira ina pogwiritsa ntchito mawonekedwe a data.

Markup

Pazifukwa zogwirira ntchito, Tooltip ndi Popover data-apis alowa. Ngati mukufuna kuzigwiritsa ntchito ingotchulani kusankha.

Njira

$().popover(zosankha)

Imayambitsa ma popover pazosonkhanitsira zinthu.

.popover('show')

Imawulula ma element popover.

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

.popover('bisala')

Imabisa zinthu zotuluka.

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

.popover('kusintha')

Imatembenuza ma element popover.

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

.popover('kuwononga')

Imabisa ndikuwononga kufalikira kwa chinthu.

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

Zidziwitso zachitsanzo

Onjezani magwiridwe antchito ku mauthenga onse ochenjeza omwe ali ndi pulogalamu yowonjezera iyi.

Woyera guacamole! Chabwino, fufuzani nokha, simukuwoneka bwino kwambiri.

O mwachangu! Mwalakwitsa!

Sinthani ichi ndi icho ndikuyesanso. Ndife mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.

Chitani izi Kapena chitani izi


Kugwiritsa ntchito

Yambitsani kuchotsedwa kwa chenjezo kudzera pa JavaScript:

  1. $ ( ".chidziwitso" ). chenjezo ()

Markup

Ingowonjezerani data-dismiss="alert"ku batani lanu lakutseka kuti mungopereka chidziwitso chapafupi.

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

Njira

$().chenjezo()

Zimangiriza zidziwitso zonse ndi magwiridwe antchito apafupi. Kuti zidziwitso zanu ziwonetsedwe zikatsekedwa, onetsetsani kuti zili .fadendi .inkalasi zomwe zagwiritsidwa ntchito kale.

.chenjezo('kutseka')

Kutseka chenjezo.

  1. $ ( ".chidziwitso" ). chenjezo ( 'close' )

Zochitika

Gulu lachidziwitso la Bootstrap limawulula zochitika zingapo kuti zigwirizane ndi zochitika zochenjeza.

Chochitika Kufotokozera
pafupi Chochitika ichi chimayaka nthawi yomweyo closenjira yachitsanzo itayitanidwa.
chatsekedwa Chochitikachi chimachotsedwa pamene chenjezo latsekedwa (lidikirira kuti kusintha kwa css kumalize).
  1. $ ( '#chenjezo langa' ). kumanga ( 'kotsekedwa' , ntchito () {
  2. // kuchitapo kanthu...
  3. })

Zitsanzo ntchito

Chitani zambiri ndi mabatani. Batani lowongolera likunena kapena pangani magulu a mabatani azinthu zambiri ngati zida.

Zomveka

Onjezani data-loading-text="Loading..."kuti mugwiritse ntchito potsitsa batani.

  1. <button type = "button" class = "btn btn-primary" data-loading-text = "Ikutsegula..." > Malo otsegula </button>

Kusintha kumodzi

Onjezani data-toggle="button"kuti mutsegule batani limodzi.

  1. <button type = "button" class = "btn btn-primary" data-toggle = "batani" > Kusintha Kumodzi </button>

Chongani bokosi

Onjezani data-toggle="buttons-checkbox"kalembedwe kabokosi kosinthira pa btn-group.

  1. <div class = "btn-group" data-toggle = "mabatani-checkbox" >
  2. <button type = "button" class = "btn btn-primary" > Kumanzere </ batani>
  3. <button type = "button" class = "btn btn-primary" > Pakati </button>
  4. <button type = "button" class = "btn btn-primary" > Kumanja </ batani>
  5. </div>

Wailesi

Onjezani data-toggle="buttons-radio"kalembedwe ka wailesi pa btn-group.

  1. <div class = "btn-group" data-toggle = "mabatani-wailesi" >
  2. <button type = "button" class = "btn btn-primary" > Kumanzere </ batani>
  3. <button type = "button" class = "btn btn-primary" > Pakati </button>
  4. <button type = "button" class = "btn btn-primary" > Kumanja </ batani>
  5. </div>

Kugwiritsa ntchito

Yambitsani mabatani kudzera pa JavaScript:

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

Markup

Makhalidwe a data ndi ofunikira pa batani lowonjezera. Onani chitsanzo pansipa chamitundu yosiyanasiyana yolembera.

Zosankha

Palibe

Njira

$().batani('kusintha')

Imatembenuza dziko lokankhira. Imawonetsa batani kuwonekera kuti yayatsidwa.

Mungodziwiratu! Mutha kuloleza kusuntha kwa batani pogwiritsa ntchito mawonekedwe data-toggle.
  1. <button type = "button" class = "btn" data-toggle = "batani" > </button>

$().batani('kutsegula')

Imakhazikitsa mawonekedwe a batani kuti mutsegule - imalepheretsa mabatani ndikusintha mawu pokweza mawu. Kutsegula mawu kuyenera kufotokozedwa pa batani pogwiritsa ntchito mawonekedwe a data data-loading-text.

  1. <button type = "button" class = "btn" data-loading-text = "kutsitsa zinthu..." > ... </button>
Mungodziwiratu! Firefox imapitilirabe mkhalidwe wolumala pamasamba onse . Njira yothetsera izi ndikugwiritsa ntchito autocomplete="off".

$(). batani ('kukonzanso')

Bwezerani mawonekedwe a batani - kusintha mawu kukhala mawu oyamba.

$(). batani (chingwe)

Bwezerani mawonekedwe a batani - kusinthana mawu kumtundu uliwonse wa data.

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

Za

Pezani masitayelo oyambira ndi chithandizo chosinthika cha zinthu zomwe zimatha kugwa monga ma accordion ndi navigation.

* Imafunikira pulogalamu yowonjezera ya Transitions kuti iphatikizidwe.

Chitsanzo cha accordion

Pogwiritsa ntchito pulogalamu yowonjezera ya kugwa, tinapanga widget yosavuta ya accordion:

Pankhani ya cliche reprehenderit, enim eiusmod high life accsamamus terry richardson ad squid. 3 Wolf moon officia aute, non cupidatat skateboard dolor brunch. Zakudya zamagalimoto quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua kuika mbalame pa nyamayo nyama imodzi yochokera khofi nulla guessnda shoreditch et. Nihil anim keffiyeh helvetica, ntchito ya mowa wa craft wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft craft famu-to-table, denim yaiwisi yokongoletsedwa ndi nesciunt mwina simunamvepo za iwo accusamus laboratory yokhazikika VHS.
Pankhani ya cliche reprehenderit, enim eiusmod high life accsamamus terry richardson ad squid. 3 Wolf moon officia aute, non cupidatat skateboard dolor brunch. Zakudya zamagalimoto quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua kuika mbalame pa nyamayo nyama imodzi yochokera khofi nulla guessnda shoreditch et. Nihil anim keffiyeh helvetica, ntchito ya mowa wa craft wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft craft famu-to-table, denim yaiwisi yokongoletsedwa ndi nesciunt mwina simunamvepo za iwo accusamus laboratory yokhazikika VHS.
Pankhani ya cliche reprehenderit, enim eiusmod high life accsamamus terry richardson ad squid. 3 Wolf moon officia aute, non cupidatat skateboard dolor brunch. Zakudya zamagalimoto quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua kuika mbalame pa nyamayo nyama imodzi yochokera khofi nulla guessnda shoreditch et. Nihil anim keffiyeh helvetica, ntchito ya mowa wa craft wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft craft famu-to-table, denim yaiwisi yokongoletsedwa ndi nesciunt mwina simunamvepo za iwo accusamus laboratory yokhazikika VHS.
  1. <div class = "accordion" id = "accordion2" >
  2. <div class = "gulu la accordion" >
  3. <div class = "accordion-heading" >
  4. <a class = "accordion-toggle" data-toggle = "collapse" data-parent = "#accordion2" href = "#collapseOne"> _
  5. Gulu #1
  6. </a>
  7. </div>
  8. <div id = "collapseOne" class = "accordion-body collapse in" >
  9. <div class = "accordion-inner" >
  10. Dziwani zambiri ...
  11. </div>
  12. </div>
  13. </div>
  14. <div class = "gulu la accordion" >
  15. <div class = "accordion-heading" >
  16. <a class = "accordion-toggle" data-toggle = "collapse" data-parent = "#accordion2" href = "#collapseTwo"> _
  17. Gulu #2
  18. </a>
  19. </div>
  20. <div id = "collapseTwo" class = "accordion-body collapse" >
  21. <div class = "accordion-inner" >
  22. Dziwani zambiri ...
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. ...

Mutha kugwiritsanso ntchito pulogalamu yowonjezera popanda chizindikiro cha accordion. Pangani batani kuti musinthe kukulitsa ndi kugwa kwa chinthu china.

  1. <button type = "button" class = "btn btn-danger" data-toggle = "collapse" data-target = "#demo" >
  2. zosavuta kukomoka
  3. </ batani>
  4.  
  5. <div id = "demo" class = "kugwera mkati" > </div>

Kugwiritsa ntchito

Kudzera muzochita za data

Ingowonjezerani data-toggle="collapse"ndi data-targetchinthu kuti muzitha kuwongolera chinthu chomwe chimatha kutha. Malingaliro data-targetamavomereza chosankha cha css kuti agwiritse ntchito kugwa. Onetsetsani kuti mwawonjezera kalasi collapseku chinthu chomwe chimatha. Ngati mukufuna kuti isatseguke, onjezani kalasi yowonjezera in.

Kuti muwonjeze kasamalidwe kagulu ka accordion ku chiwongolero chosokonekera, onjezani mawonekedwe a data data-parent="#selector". Onani pachiwonetsero kuti muwone izi zikugwira ntchito.

Kudzera pa JavaScript

Yambitsani pamanja ndi:

  1. $ ( ".kugwa" ). kugwa ()

Zosankha

Zosankha zitha kuperekedwa kudzera pa data kapena JavaScript. Pamawonekedwe a data, yonjezerani dzina lachisankho ku data-, monga mu data-parent="".

Dzina mtundu kusakhulupirika kufotokoza
kholo wosankha zabodza Ngati chosankha ndiye kuti zinthu zonse zomwe zimasokonekera pansi pa kholo lotchulidwa zidzatsekedwa chinthu chosokonekerachi chikuwonetsedwa. (zofanana ndi chikhalidwe cha accordion)
kusintha boolean zoona Imasintha chinthu chomwe chimasokonekera pakuyitanitsa

Njira

.kugwa(zosankha)

Imatsegula zomwe zili patsamba lanu ngati chinthu chosokonekera. Imavomereza zomwe mungachite object.

  1. $ ( '#myCollapsible' ). kugwa ({
  2. toggle : zabodza
  3. })

.kugwa ('kusintha')

Imasintha zinthu zomwe zimagundika kuti ziwonetsedwe kapena zobisika.

.kugwa('show')

Imawonetsa chinthu chomwe chimatha kutha.

.gwa ('bisala')

Imabisa chinthu chomwe chimatha kutha.

Zochitika

Gulu la kugwa la Bootstrap limawulula zochitika zingapo kuti zigwirizane ndi kugwa.

Chochitika Kufotokozera
chiwonetsero Chochitika ichi chimayaka nthawi yomweyo shownjira yachitsanzo itayitanidwa.
zowonetsedwa Chochitikachi chimachotsedwa pomwe chinthu chakugwa chawonetsedwa kwa wogwiritsa ntchito (chidikirira kuti kusintha kwa css kumalize).
kubisa Chochitikachi chimathamangitsidwa nthawi yomweyo hidenjirayo itayitanidwa.
zobisika Chochitikachi chimachotsedwa pomwe chinthu chakugwa chabisidwa kwa wogwiritsa ntchito (chidikirira kuti kusintha kwa css kumalize).
  1. $ ( '#myCollapsible' ). pa ( 'zobisika' , ntchito () {
  2. // kuchitapo kanthu...
  3. })

Chitsanzo

Pulagi yoyambira, yotalikira mosavuta yopangira mwachangu zilembo zokongola ndi mawu amtundu uliwonse.

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

Mufuna kukhazikitsa autocomplete="off"kuti mulepheretse mindandanda yamasewera osasinthika kuti asawonekere pazotsitsa za Bootstrap.


Kugwiritsa ntchito

Kudzera muzochita za data

Onjezani mawonekedwe a data kuti mulembetse chinthu chokhala ndi typeahead monga momwe tawonetsera pachitsanzo pamwambapa.

Kudzera pa JavaScript

Imbani typeahead pamanja ndi:

  1. $ ( '.typeahead' ). mtundu ()

Zosankha

Zosankha zitha kuperekedwa kudzera pa data kapena JavaScript. Pamawonekedwe a data, yonjezerani dzina lachisankho ku data-, monga mu data-source="".

Dzina mtundu kusakhulupirika kufotokoza
gwero array, ntchito [] Gwero la data loti mufunse motsutsa. Zitha kukhala zingwe zingapo kapena ntchito. Ntchitoyi yadutsa mikangano iwiri, querymtengo mu gawo lolowera ndi processcallback. Ntchitoyi ingagwiritsidwe ntchito mofananamo pobweza gwero la deta mwachindunji kapena mosasinthasintha kudzera processmkangano umodzi wa callback.
zinthu nambala 8 Nambala yochulukitsitsa yazinthu zomwe zikuwonetsedwa pazotsitsa.
minLength nambala 1 Kutalika kwa zilembo kumafunika musanayambitse malingaliro omaliza okha
wofananira ntchito osamva kanthu Njira yomwe imagwiritsidwa ntchito kudziwa ngati funso likugwirizana ndi chinthu. Amavomereza mkangano umodzi, itemwomwe ungayesere funso. Pezani funso lapano ndi this.query. Bweretsani boolean truengati funso likufanana.
sintha ntchito zofananira ndendende,
kukhudzidwa kwa
nkhani, kusakhudzidwa ndi vuto
Njira yomwe imagwiritsidwa ntchito posankha zotsatira zomaliza zokha. Imavomereza mkangano umodzi itemsndipo imakhala ndi gawo la chitsanzo cha typeahead. Lowetsani funso lomwe lilipo ndi this.query.
updater ntchito imabweretsanso chinthu chosankhidwa Njira yobwezera yomwe mwasankha. Amavomereza mkangano umodzi, itemndipo ali ndi kuchuluka kwa chitsanzo cha typeahead.
chowunikira ntchito ikuwonetsa mafananidwe onse osasinthika Njira yomwe imagwiritsidwa ntchito powunikira zotsatira zomaliza zokha. Imavomereza mkangano umodzi itemndipo imakhala ndi gawo la chitsanzo cha typeahead. Iyenera kubwereranso html.

Njira

.typeahead(zosankha)

Imayambitsa zolowetsa ndi typeahead.

Chitsanzo

Ma subnavigation kumanzere ndi chiwonetsero chamoyo cha pulogalamu yowonjezera.


Kugwiritsa ntchito

Kudzera muzochita za data

Kuti muwonjezere mosavuta khalidwe la affix ku chinthu chilichonse, ingowonjezerani data-spy="affix"ku chinthu chomwe mukufuna kuti muzichiyang'ana. Kenako gwiritsani ntchito ma offsets kutanthauzira nthawi yosinthira kuyika ndi kutseka chinthu.

  1. <div data-spy = "affix" data-offset-top = "200" > ... </div>
Mungodziwiratu! Muyenera kuyang'anira malo a chinthu chokhomedwa ndi machitidwe a kholo lake. Udindo umayendetsedwa ndi affix, affix-top, ndi affix-bottom. Kumbukirani kuyang'ana kholo lomwe lingathe kugwa pamene cholembera chikulowa pamene chikuchotsa zomwe zili patsamba.

Kudzera pa JavaScript

Imbani pulogalamu yowonjezera kudzera pa JavaScript:

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

Zosankha

Zosankha zitha kuperekedwa kudzera pa data kapena JavaScript. Pamawonekedwe a data, yonjezerani dzina lachisankho ku data-, monga mu data-offset-top="200".

Dzina mtundu kusakhulupirika kufotokoza
kuchepetsa nambala | ntchito | chinthu 10 Ma pixel oti muchotse pa skrini powerengera malo osindikizira. Ngati nambala imodzi yaperekedwa, chotsitsacho chidzagwiritsidwa ntchito kumtunda ndi kumanzere. Kuti mumvetsere njira imodzi, kapena zosintha zingapo zapadera, ingoperekani chinthu offset: { x: 10 }. Gwiritsani ntchito ngati mukufuna kupereka chosinthira (chothandiza pamapangidwe ena omvera).