JavaScript

Whakaorangia nga waahanga o Bootstrap-inaianei me nga taputapu jQuery ritenga 13.

Mahunga ake! Ko enei tuhinga mo te v2.3.2, kaore i te tautoko mana. Tirohia te putanga hou o Bootstrap!

Takitahi, whakahiato ranei

Ka taea te whakauru takitahi nga monomai (ahakoa e hiahia ana etahi ki te whakawhirinaki), me te katoa i te wa kotahi. Kei roto i nga bootstrap.js me bootstrap.min.js nga monomai katoa i roto i te konae kotahi.

Nga huanga raraunga

Ka taea e koe te whakamahi i nga taputapu Bootstrap katoa ma te tohu tohu API me te kore e tuhi i tetahi rarangi JavaScript. Koinei te API karaehe tuatahi a Bootstrap a me whakaaro tuatahi koe ina whakamahi ana i te mono.

E ai ki tera, i etahi ahuatanga ka pai ki te whakaweto i tenei mahi. Na reira, ka tukuna ano e matou te kaha ki te whakakore i te API huanga raraunga ma te wetewete i nga huihuinga katoa i runga i te ingoa o te tinana kua tohua ki te `'data-api'`. Ko te ahua tenei:

  1. $ ( 'tinana' ). weto ( '.data-api' )

Hei taapiri, ki te aro ki tetahi mono motuhake, whakauruhia te ingoa o te mono hei mokowāingoa me te mokowāingoa raraunga-api penei:

  1. $ ( 'tinana' ). weto ( '.alert.data-api' )

API Papatono

E whakapono ana matou ka taea e koe te whakamahi i nga taputapu Bootstrap katoa ma te JavaScript API. Ko nga API whanui katoa he tikanga kotahi, ka taea te mekameka, ka whakahoki i te kohinga i mahia.

  1. $ ( ".btn.danger" ). pātene ( "takahuri" ). addClass ( "ngako" )

Ko nga tikanga katoa me whakaae ki tetahi ahanoa kōwhiringa, he aho e aro ana ki tetahi tikanga, kaore ranei (e timata ana i te mono me te whanonga taunoa):

  1. $ ( "#myModal" ). modal () // kua arawhiti me nga taunoa
  2. $ ( "#myModal" ). modal ({ papapātuhi : teka }) // i arawhiti me te kore papapātuhi
  3. $ ( "#myModal" ). modal ( 'whakaatu' ) // arawhiti me te karanga whakaatu tonu

Ka whakaatu hoki ia mono i tana kaihanga mata ki runga i tetahi taonga `Constructor`: $.fn.popover.Constructor. Mena kei te pirangi koe ki te tiki i tetahi tauira mono, tiki tika mai i tetahi huānga: $('[rel=popover]').data('popover').

Karekau he taupatupatu

I etahi wa ka tika te whakamahi i nga taputapu Bootstrap me etahi atu angamahi UI. I roto i enei ahuatanga, ka taea e nga tukinga mokowā ingoa i etahi wa. Mena ka pa mai tenei, ka waea atu koe .noConflictki te mono e hiahia ana koe ki te whakahoki i te uara o.

  1. var bootstrapButton = $ . fn . pātene . noConflict () // whakahokia te $.fn.button ki te uara kua whakaritea i mua
  2. $ . fn . bootstrapBtn = bootstrapButton // hoatu $().bootstrapBtn te mahi bootstrap

Nga huihuinga

Ka whakaratohia e Bootstrap nga huihuinga ritenga mo te nuinga o nga mahi ahurei a te mono. Ko te tikanga, ka puta mai enei i roto i te ahua infinitive me te puka participle o mua - kei reira te infinitive (ex. show) ka puta i te tiimatanga o te huihuinga, me tana puka participle o mua (ex. shown) ka puta i te otinga o te mahi.

Ko nga takahanga mutunga kore ka whakarato i te mahi aukatiTaunoa. Ma tenei ka taea te aukati i te mahi i mua i te tiimata.

  1. $ ( '#myModal' ). kei runga ( 'whakaatu' , mahi ( e ) {
  2. ki te hoki mai ( ! raraunga ) e . preventDefault () // ka mutu te whakaatu i te tikanga
  3. })

Mo nga whakawhitinga

Mo nga paanga whakawhiti ngawari, whakaurua bootstrap-transition.js kotahi ki te taha o etahi atu konae JS. Mena kei te whakamahi koe i te bootstrap.js kua whakaemihia (me iti ranei) , kaore he take ki te whakauru i tenei—kei kona ano.

Whakamahia nga keehi

Ko etahi tauira o te mono whakawhiti:

  • Te whakaheke, te memenge ranei i roto i nga tikanga
  • Ka memeha atu nga ripa
  • Matohi ka memeha haere
  • Pihanga carousel retireti

Tauira

Ko nga tauira he mea whakamaarama, engari he ngawari, he korero akiaki me te iti rawa o nga mahi e hiahiatia ana me nga taunoa atamai.

Tauira pateko

He tikanga tuku me te pane, te tinana, me te huinga hohenga kei te hiku.

  1. <div class = "Modal hide fade" >
  2. <div class = "modal-header" >
  3. <button type = "button" class = "close" data-dismiss = "modal" aria-huna = "pono" > &wa; </pātene>
  4. <h3> pane pane </h3>
  5. </div>
  6. <div class = "modal-body" >
  7. <p> Kotahi te tinana pai… </p>
  8. </div>
  9. <div class = "modal-footer" >
  10. <a href = "#" class = "btn" > Katia </a>
  11. <a href = "#" class = "btn btn-primary" > Tiakina nga huringa </a>
  12. </div>
  13. </div>

Demo ora

Takahurihia he tikanga ma te JavaScript ma te paatene i te paatene kei raro nei. Ka paheke ki raro ka memeha mai i te tihi o te wharangi.

  1. <!-- Patene hei whakaoho i te tikanga -->
  2. <a href = "#myModal" role = "button" class = "btn" data-toggle = "modal" > Whakarewahia te aratau demo </a>
  3.  
  4. <!-- Modal -->
  5. <div id = "myModal" class = "Modal hide fade" tabindex = "-1" role = "dialog" aria-labelledby = "myModalLabel" aria-huna = "pono" >
  6. <div class = "modal-header" >
  7. <button type = "button" class = "close" data-dismiss = "modal" aria-hidden = "pono" > × </button>
  8. <h3 id = "myModalLabel" > pane pane </h3>
  9. </div>
  10. <div class = "modal-body" >
  11. <p> Kotahi te tinana pai… </p>
  12. </div>
  13. <div class = "modal-footer" >
  14. <button class = "btn" data-dismiss = "modal" aria-hidden = "pono" > Katia </button>
  15. <button class = "btn btn-primary" > Tiakina nga huringa </button>
  16. </div>
  17. </div>

Whakamahinga

Ma nga huanga raraunga

Whakahohehia he tikanga me te kore e tuhi JavaScript. Whakatakotoria data-toggle="modal"ki runga i te huānga mana whakahaere, penei i te paatene, me te, ki te whai data-target="#foo"ranei href="#foo"i tetahi aratau motuhake hei takahuri.

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

Ma te JavaScript

Karangahia he tikanga me te id myModalme te rarangi kotahi o JavaScript:

  1. $ ( '#myModal' ). modal ( kōwhiringa )

Kōwhiringa

Ko nga whiringa ka taea te tuku ma nga huanga raraunga, JavaScript ranei. Mo nga huanga raraunga, apitihia te ingoa whiringa ki data-, penei i te data-backdrop="".

Ingoa momo taunoa whakaahuatanga
papamuri boolean pono Kei roto he huānga tauira-papamuri. Arā, whakawhāitihia statiche papamuri e kore e kati i te aratau i runga i te paatene.
papapātuhi boolean pono Ka kati i te aratau ina pehia te ki mawhiti
whakaatu boolean pono Ka whakaatu i te aratau ina arawhiti.
mamao ara teka

Mena ka tukuna he url mamao, ka utaina nga ihirangi ma te loadtikanga a jQuery ka werohia ki te .modal-body. Mena kei te whakamahi koe i te api raraunga, ka taea e koe te whakamahi i te hreftohu hei tohu i te puna mamao. Ko tetahi tauira o tenei e whakaatuhia ana i raro nei:

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

Nga tikanga

.modal(kōwhiringa)

Whakahohehia to ihirangi hei aratau. Ka whakaae ki nga whiringa whiriwhiri object.

  1. $ ( '#myModal' ). tikanga ({
  2. papapātuhi : teka
  3. })

.modal('takahuri')

Ka takahuri-a-ringa i te tikanga.

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

.modal('whakaatu')

Ka whakatuwhera a-ringa i te tikanga.

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

.modal('huna')

Ka huna a-ringa i tetahi tikanga.

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

Nga huihuinga

Ko te karaehe aratau a Bootstrap e whakaatu ana i etahi huihuinga mo te hono atu ki nga mahi tikanga.

Takahanga Whakaahuatanga
whakaatu Ka pupuhi tenei takahanga ina ka showkarangahia te aratuka tauira.
whakaaturia Ka puhia tenei takahanga i te wa i kitea ai te aratau ki te kaiwhakamahi (ka tatari kia oti nga whakawhitinga css).
huna Ka puhia tonutia tenei takahanga ina hidekua karangahia te aratuka tauira.
huna Ka puhia tenei takahanga ina mutu te hunanga o te tikanga mai i te kaiwhakamahi (ka tatari kia oti nga whakawhitinga css).
  1. $ ( '#myModal' ). kei runga ( 'huna' , mahi () {
  2. // mahia tetahi mea…
  3. })

Tauira i roto i te navbar

Ko te mono ScrollSpy mo te whakahou aunoa i nga whaainga nav i runga i te tuunga panuku. Panuku i te waahi kei raro i te pae whakatere ka mataki i te huringa o te karaehe hohe. Ka miramirahia nga mea iti takaiho.

@ngako

Ad leggings keytar, brunch id toi party dolor laboure. Pitchfork yr enim lo-fi i mua i to ratou hoko atu. Tumblr pāmu-ki-tepu mana pahikara ahakoa. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Ko nga tarau tarau jean koti, williamsburg hoodie minim qui kaore pea koe i rongo mo ena me te cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artistan ullamco consequat.

@mdo

Veniam marfa mustache papareti, adipisicing fugiat velit pitchfork pahau. Freegan pahau aliqua cupidatat mcsweeney's vero. Cupidatat wha loko nisi, ea helvetica nulla carles. Taraka kai taraka kai moko, ko te quis non freegan vinyl a mcsweeney. Lo-fi wes anderson +1 sartorial. Carles non aesthetic exercitation quis gentrify. Brooklyn adipisicing craft beer vice keytar deserunt.

kotahi

Occaecat commodo aliqua delectus. Fap craft beer deserunt skateboard ea. Te mana paihikara Lomo 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. Ko te Vero VHS he tino pai. Consectetur etahi DIY iti putea karere. Ko te whakaaro o mua i roto i te, tauwhiro delectus consectetur fanny pack iphone.

rua

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 ahakoa he taraka kai. Sapiente synth id assumenda. Locavore sed helvetica cliche irony, thundercats kaore pea koe i rongo mo ratou e consequat hoodie gluten-free lo-fi fap aliquip. Whakamahia he waahi i mua i te hokonga atu, ko terry richardson proident brunch nesciunt quis cosby sweater pariatur keffiyeh ut helvetica artistan. Cardigan craft beer seitan readymade velit. VHS chambray laboris tempor veniam. Anim mollit minim commodo ullamco thundercats.


Whakamahinga

Ma nga huanga raraunga

Kia ngawari te taapiri i te whanonga scrollspy ki to whakatere pae runga, taapiri noa data-spy="scroll"ki te huānga e hiahia ana koe ki te tutei (te nuinga ko te tinana tenei) me data-target=".navbar"te whiriwhiri ko tehea nav hei whakamahi. Ka hiahia koe ki te whakamahi i te scrollspy me tetahi .navwaahanga.

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

Ma te JavaScript

Karangatia te scrollspy mā JavaScript:

  1. $ ( '#navbar' ). scrollspy ()
Mahunga ake! Ko nga hononga Navbar me whai tohu id ka taea te whakatau. Hei tauira, <a href="#home">home</a>me rite ki tetahi mea i roto i te dom rite <div id="home"></div>.

Nga tikanga

.scrollspy('whakahou')

Ina whakamahi i te scrollspy me te taapiri, te tango ranei i nga huānga mai i te DOM, me waea koe ki te tikanga whakahou penei:

  1. $ ( '[data-spy="scroll"]' ). ia ( mahi () {
  2. var $spy = $ ( tenei ). scrollspy ( 'whakahou' )
  3. });

Kōwhiringa

Ko nga whiringa ka taea te tuku ma nga huanga raraunga, JavaScript ranei. Mo nga huanga raraunga, apitihia te ingoa whiringa ki data-, penei i te data-offset="".

Ingoa momo taunoa whakaahuatanga
whakatiki tau 10 Pika hei whakatiki mai i runga i te tatau i te waahi o te panuku.

Nga huihuinga

Takahanga Whakaahuatanga
whakahohe Ka pupuhi tenei takahanga i nga wa katoa ka whakahohehia he mea hou e te scrollspy.

Tauira ripa

Tāpirihia te mahinga ripa tere, hihiko ki te whakawhiti i roto i nga pihanga o nga ihirangi o te rohe, ahakoa ma nga tahua takaiho.

Kare pea koe i rongo ki a ratou he tarau jean Austin. Nesciunt tofu stumptown aliqua, retro synth master horoi. Moutere cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex wheke. A tuu i te salvia cillum iphone. Seitan aliquip quis cardigan kakahu a Amerika, te kai patu patu i etahi 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.


Whakamahinga

Whakahohehia nga ripa ripa ma te JavaScript (me whakahohe takitahi ia ripa):

  1. $ ( '#myTab a' ). pawhiria ( mahi ( e ) {
  2. e . āraiTaunoa ();
  3. $ ( tenei ). ripa ( 'whakaatu' );
  4. })

Ka taea e koe te whakahohe i nga ripa takitahi i roto i nga huarahi maha:

  1. $ ( '#myTab a[href="#profile"]' ). ripa ( 'whakaatu' ); // Tīpakohia te ripa mā te ingoa
  2. $ ( '#myTab a:tuatahi' ). ripa ( 'whakaatu' ); // Tīpakohia te ripa tuatahi
  3. $ ( '#myTab a: last' ). ripa ( 'whakaatu' ); // Tīpakohia te ripa whakamutunga
  4. $ ( '#myTab li:eq(2) a' ). ripa ( 'whakaatu' ); // Tīpakohia te ripa tuatoru (0-taupū)

Tohutohu

Ka taea e koe te whakahohe i te whakatere ripa, pire ranei me te kore e tuhi i tetahi JavaScript ma te tohu noa , ki runga data-toggle="tab"ranei data-toggle="pill"i tetahi huānga. Ko te taapiri i nga karaehe navme nav-tabsnga karaehe ki te ripa ulka whakamahia te ahua o te ripa Bootstrap.

  1. <ul class = "nav nav-ripa" >
  2. <li><a href = "#home" data-toggle = "tab" > Home </a> </li>
  3. <li><a href = "#profile" data-toggle = "ripa" > Kōtaha </a> </li>
  4. <li><a href = "#messages" data-toggle = "ripa" > Karere </a> </li>
  5. <li><a href = "#settings" data-toggle = "ripa" > Tautuhinga </a> </li>
  6. </ul>

Nga tikanga

$(). ripa

Ka whakahohe i te huānga ripa me te ipu ihirangi. Me whai Ripa he data-target, he hrefkohanga ipu ranei kei roto i te DOM.

  1. <ul class = "nav nav-tabs" id = "myTab" >
  2. <li class = "active" ><a href = "#home" > Home </a> </li>
  3. <li><a href = "#profile" > Kōtaha </a> </li>
  4. <li><a href = "#karere" > Nga Karere </a> </li>
  5. <li><a href = "#settings" > Tautuhinga </a> </li>
  6. </ul>
  7.  
  8. <div class = "ripa-ihirangi" >
  9. <div class = "tab-pane active" id = "home" > ... </div>
  10. <div class = "tab-pane" id = "profile" > ... </div>
  11. <div class = "tab-pane" id = "nga karere" > ... </div>
  12. <div class = "tab-pane" id = "tautuhinga" > ... </div>
  13. </div>
  14.  
  15. <hōtuhi>
  16. $ ( mahi () {
  17. $ ( '#myTab a: last' ). ripa ( 'whakaatu' );
  18. })
  19. </script>

Nga huihuinga

Takahanga Whakaahuatanga
whakaatu Ka pupuhi tenei takahanga ki te whakaaturanga ripa, engari i mua i te whakaaturanga o te ripa hou. Whakamahia event.targetme event.relatedTargette aro ki te ripa hohe me te ripa hohe o mua (mehemea e waatea ana).
whakaaturia Ka ahi tenei takahanga ki te whakaaturanga ripa i muri i te whakaaturanga ripa. Whakamahia event.targetme event.relatedTargette aro ki te ripa hohe me te ripa hohe o mua (mehemea e waatea ana).
  1. $ ( 'a[data-toggle="ripa"]' ). kei runga ( 'whakaatuhia' , mahi ( e ) {
  2. e . ūnga // ripa whakahohe
  3. e . relatedTarget // ripa o mua
  4. })

Tauira

I whakaaweahia e te mono jQuery.tipsy pai i tuhia e Jason Frame; Ko nga aki-utauta he putanga whakahou, kaore e whakawhirinaki ki nga whakaahua, whakamahi CSS3 mo nga pakiwaituhi, me nga huanga-raraunga mo te rokiroki taitara rohe.

Mo nga take mahi, ka uru mai te aki taputapu me te popover data-apis, ko te tikanga me arawhiti koe i a koe .

Whakaparo ki runga i nga hononga i raro nei kia kite i nga aki taputapu:

Ko nga tarau tarau karekau pea koe i rongo. Pua whakaahua pahau denim mata reta vegan putea karere stumptown. Ko te quinoa 8-bit te kakahu o Amerika he terry richardson's fixie a mcsweeney's fixie te kakahu o Amerika he terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, e wha te purenga vegan chambray a loko mcsweeney. He tohunga toi tino whakahiato ahakoa te keytar , scenester farm-to-table banksy Austin twitter handle freegan cred raw denim single-origin coffee viral.

E wha nga ahunga

Aki taputapu i roto i nga roopu whakauru

I te wa e whakamahi ana koe i nga aki taputapu me nga popovers me nga roopu whakauru Bootstrap, me whakarite e koe te containerwhiringa (kua tuhia ki raro) hei karo i nga paanga taha kino.


Whakamahinga

Whakaohohia te aki taputapu ma te JavaScript:

  1. $ ( '#tauira' ). aki taputapu ( kōwhiringa )

Kōwhiringa

Ko nga whiringa ka taea te tuku ma nga huanga raraunga, JavaScript ranei. Mo nga huanga raraunga, apitihia te ingoa whiringa ki data-, penei i te data-animation="".

Ingoa momo taunoa whakaahuatanga
hākoritanga boolean pono hoatu he whakawhiti memeha css ki te aki taputapu
html boolean teka Whakauruhia te html ki te aki taputapu. Mena he teka, textka whakamahia te tikanga a jquery ki te whakauru ihirangi ki te dom. Whakamahia te kuputuhi mena kei te awangawanga koe mo nga whakaeke XSS.
whakanohonga aho | mahi 'runga' me pehea te whakanoho i te aki taputapu - runga | raro | maui | tika
kaiwhiriwhiri aho teka Mena ka tukuna he kaiwhiriwhiri, ka tukuna nga taonga aki taputapu ki nga whaainga kua tohua.
taitara aho | mahi '' uara taitara taunoa mena karekau he tohu `taitara`
keu aho 'whakaaro arotahi' pehea te aki utauta e whakaohohia ana - pawhiria | whakaparo | arotahi | ā-ringa. Kia mahara koe he maha nga keu keu, he waahi wehe, he momo keu.
whakaroa tau | ahanoa 0

whakaroa te whakaatu me te huna i te aki taputapu (ms) - kaore e pa ki te momo keu a-ringa

Mena ka tukuna he nama, ka tukuna he whakaroa ki te huna/whakakitenga e rua

Ko te hanganga ahanoa:delay: { show: 500, hide: 100 }

ipu aho | teka teka

He taapiri i te aki taputapu ki tetahi huānga motuhakecontainer: 'body'

Mahunga ake! Ko nga whiringa mo nga aki taputapu takitahi ka taea te whakarite ma te whakamahi i nga huanga raraunga.

Tohutohu

  1. <a href = "#" data-toggle = "taputapu" title = "matautauta tuatahi" > whakaparo ki runga i ahau </a>

Nga tikanga

$().tiputauta(kwhiringa)

Ka taapirihia he kaihautu taputapu ki tetahi kohinga huānga.

.utautauta('whakaatu')

He whakaatu i te aki taputapu o tetahi huānga.

  1. $ ( '#huānga' ). aki taputapu ( 'whakaatu' )

.utautauta('huna')

Hunaia te aki taputapu o tetahi huānga.

  1. $ ( '#huānga' ). aki taputapu ( 'huna' )

.utautauta('takahuri')

Ka takahurihia te akiutauta o tetahi huānga.

  1. $ ( '#huānga' ). aki taputapu ( 'takahuri' )

.utautauta('whakangaromia')

He huna me te whakangaro i te aki taputapu o tetahi huānga.

  1. $ ( '#huānga' ). aki taputapu ( 'whakangaromia' )

Tauira

Tāpirihia nga whakakikorua iti o te ihirangi, penei i era i runga i te iPad, ki tetahi huānga mo nga korero tuarua mo te whare. Whakaparo ki runga i te paatene hei whakaoho i te pouver. Me whakauru te Akiutauta .

Pouaka pateko

E wha nga whiringa e waatea ana: runga, matau, raro me te taha maui.

Te tihi o runga

Ko te posuere consectetur est at lobortis. Aenean eu leo ​​quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Poover matau

Ko te posuere consectetur est at lobortis. Aenean eu leo ​​quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Popover raro

Ko te posuere consectetur est at lobortis. Aenean eu leo ​​quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Ka mahue a Popover

Ko te posuere consectetur est at lobortis. Aenean eu leo ​​quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Karekau he tohu e whakaatuhia ana ko nga popovers ka puta mai i te JavaScript me nga ihirangi kei roto i tetahi datahuanga.

Demo ora

E wha nga ahunga


Whakamahinga

Whakahohehia nga popovers ma JavaScript:

  1. $ ( '#tauira' ). popover ( kōwhiringa )

Kōwhiringa

Ko nga whiringa ka taea te tuku ma nga huanga raraunga, JavaScript ranei. Mo nga huanga raraunga, apitihia te ingoa whiringa ki data-, penei i te data-animation="".

Ingoa momo taunoa whakaahuatanga
hākoritanga boolean pono hoatu he whakawhiti memeha css ki te aki taputapu
html boolean teka Kōkuhutia te html ki roto i te popover. Mena he teka, textka whakamahia te tikanga a jquery ki te whakauru ihirangi ki te dom. Whakamahia te kuputuhi mena kei te awangawanga koe mo nga whakaeke XSS.
whakanohonga aho | mahi 'tika' me pehea te whakanoho i te pouver - runga | raro | maui | tika
kaiwhiriwhiri aho teka ki te tukuna he kaiwhiriwhiri, ka tukuna nga taonga taputapu ki nga whaainga kua tohua
keu aho 'pāwhiri' me pehea te whakaoho o te popover - pawhiria | whakaparo | arotahi | ā-ringa
taitara aho | mahi '' uara taitara taunoa mena karekau te huanga `taitara`
ihirangi aho | mahi '' uara ihirangi taunoa ki te kore te huanga `raraunga-ihirangi`
whakaroa tau | ahanoa 0

whakaroa te whakaatu me te huna i te popover (ms) - kaore e pa ki te momo keu a-ringa

Mena ka tukuna he nama, ka tukuna he whakaroa ki te huna/whakakitenga e rua

Ko te hanganga ahanoa:delay: { show: 500, hide: 100 }

ipu aho | teka teka

He taapiri i te pouver ki tetahi huānga motuhakecontainer: 'body'

Mahunga ake! Ko nga whiringa mo nga popovers takitahi ka taea te tautuhi ma te whakamahi i nga huanga raraunga.

Tohutohu

Mo nga take mahi, ka uru mai te Aki Utauta me te Popover data-apis. Mena kei te pirangi koe ki te whakamahi, tohua he kowhiringa kaiwhiriwhiri.

Nga tikanga

$().popover(kōwhiringa)

Ka arataki popover mo te kohinga huānga.

.popover('whakaatu')

He whakaatu i tetahi huānga popover.

  1. $ ( '#huānga' ). popover ( 'whakaatu' )

.popover('huna')

Hunaia he huānga popover.

  1. $ ( '#huānga' ). popover ( 'huna' )

.popover('takahuri')

Ka takahuri i tetahi huānga popover.

  1. $ ( '#huānga' ). popover ( 'takahuri' )

.popover('whakangaromia')

Huna me te whakangaro i te popover o tetahi huānga.

  1. $ ( '#huānga' ). popover ( 'whakangaromia' )

Tauira matohi

Tāpirihia te mahi whakakore ki nga karere mataara katoa me tenei mono.

Guacamole tapu! He pai ake te tirotiro i a koe ano, kaore koe i te tino pai.

Aue kapo! I hapa koe!

Hurihia tenei me tera ka ngana ano. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.

Tangohia tenei mahi Me mahi ranei tenei


Whakamahinga

Whakahohehia te whakakore i te matohi ma te JavaScript:

  1. $ ( ".matohi" ). mataara ()

Tohutohu

Taapiri noa data-dismiss="alert"ki to patene kati hei hoatu aunoa i te mahi kati matohi.

  1. <a class = "kati" data-dismiss = "matohi" href = "#" > × </a>

Nga tikanga

$().matohi()

Ka takai i nga matohi katoa me te mahi tata. Kia whakakorikorihia o matohi ina katia, me mohio kei a raatau te karaehe .fademe .inte karaehe kua tukuna ki a raatau.

.matohi('kati')

Katia he matohi.

  1. $ ( ".matohi" ). mataara ( 'kati' )

Nga huihuinga

Ko te karaehe mataara a Bootstrap e whakaatu ana i etahi huihuinga mo te hono ki te mahi mataara.

Takahanga Whakaahuatanga
kati Ka pupuhi tenei takahanga ina ka closekarangahia te aratuka tauira.
katia Ka puhia tenei takahanga ina katia te matohi (ka tatari kia oti nga whakawhitinga css).
  1. $ ( '#taku-matohi' ). herea ( 'katia' , mahi () {
  2. // mahia tetahi mea…
  3. })

Tauira whakamahi

Mahi atu ki nga paatene. Ka kii te paatene mana, te hanga roopu patene ranei mo etahi atu waahanga penei i nga paeutauta.

Stateful

Tāpiri data-loading-text="Loading..."ki te whakamahi i te ahua uta ki runga i te paatene.

  1. <button type = "button" class = "btn btn-primary" data-loading-text = "Kei te uta..." > Te ahua o te uta </button>

Takahuri kotahi

Tāpirihia data-toggle="button"hei whakahohe i te takahuri i runga i te paatene kotahi.

  1. <button type = "button" class = "btn btn-primary" data-toggle = "button" > Takahuri Kotahi </button>

Pouakataki

Tāpiri data-toggle="buttons-checkbox"mo te kāhua pouakataki takahuri i runga btn-rōpū.

  1. <div class = "btn-group" data-toggle = "pātene-pouakataki" >
  2. <button type = "button" class = "btn btn-primary" > Mauī </button>
  3. <button type = "button" class = "btn btn-primary" > Waenga </button>
  4. <button type = "button" class = "btn btn-primary" > Matau </button>
  5. </div>

reo irirangi

Tāpirihia data-toggle="buttons-radio"mo te kāhua reo irirangi takahuri i runga btn-rōpū.

  1. <div class = "btn-group" data-toggle = "pātene-reo irirangi" >
  2. <button type = "button" class = "btn btn-primary" > Mauī </button>
  3. <button type = "button" class = "btn btn-primary" > Waenga </button>
  4. <button type = "button" class = "btn btn-primary" > Matau </button>
  5. </div>

Whakamahinga

Whakahohehia nga paatene ma te JavaScript:

  1. $ ( '.nav-tabs' ). pātene ()

Tohutohu

Ko nga huanga raraunga he mea nui ki te paatene mono. Tirohia te tauira waehere i raro nei mo nga momo tohu tohu.

Kōwhiringa

Karekau

Nga tikanga

$().pātene('takahuri')

Ka takahuri te ahua pana. Ka hoatu ki te paatene te ahua kua whakahohehia.

Mahunga ake! Ka taea e koe te huri aunoa i te paatene ma te whakamahi i te data-togglehuanga.
  1. <button type = "button" class = "btn" data-toggle = "button" > </button>

$().pātene('uta')

Ka tautuhi i te ahua o te paatene ki te uta - ka monohia te paatene me te huri i te kuputuhi ki te uta kuputuhi. Ko te uta kuputuhi me tautuhi ki te huānga paatene ma te whakamahi i te huanga raraunga data-loading-text.

  1. <button type = "button" class = "btn" data-loading-text = "uta mea..." > ... </button>
Mahunga ake! Ka mau tonu a Firefox i te ahua haua puta noa i nga utaina wharangi . Ko tetahi otinga mo tenei ko te whakamahi autocomplete="off".

$().pātene('tautuhi')

Ka tautuhi ano i te ahua o te paatene - ka huri i te kuputuhi ki te tuhinga taketake.

$().pātene(aho)

Ka tautuhi ano i te ahua o te paatene - ka huri i te kuputuhi ki tetahi ahuatanga kuputuhi kua tautuhia.

  1. <button type = "button" class = "btn" data-complete-text = "kua oti!" > ... </pātene>
  2. <hōtuhi>
  3. $ ( '.btn' ). pātene ( 'oti' )
  4. </script>

Tikina nga momo turanga me te tautoko ngawari mo nga waahanga tiango penei i te accordions me te whakatere.

* Me whakauru te mono Whakawhiti.

Tauira accordion

Ma te whakamahi i te mono tiango, i hangaia e matou he widget ahua accordion ngawari:

Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad wheke. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Taraka kai quinoa nesciunt laborum eiusmod. Parakuihi 3 wolf moon tempor, sunt aliqua hoatu he manu ki runga wheke kotahi-taketake kawhe nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Te reweti occaecat mahi pia paamu-ki-tepu, raw denim aesthetic synth nesciunt kaore pea koe i rongo mo ratou accusamus labore ukauka VHS.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad wheke. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Taraka kai quinoa nesciunt laborum eiusmod. Parakuihi 3 wolf moon tempor, sunt aliqua hoatu he manu ki runga wheke kotahi-taketake kawhe nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Te reweti occaecat mahi pia paamu-ki-tepu, raw denim aesthetic synth nesciunt kaore pea koe i rongo mo ratou accusamus labore ukauka VHS.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad wheke. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Taraka kai quinoa nesciunt laborum eiusmod. Parakuihi 3 wolf moon tempor, sunt aliqua hoatu he manu ki runga wheke kotahi-taketake kawhe nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Te reweti occaecat mahi pia paamu-ki-tepu, raw denim aesthetic synth nesciunt kaore pea koe i rongo mo ratou accusamus labore ukauka VHS.
  1. <div class = "accordion" id = "accordion2" >
  2. <div class = "akordion-rōpū" >
  3. <div class = "akordion-upoko" >
  4. <a class = "accordion-toggle" data-toggle = "collapse" data-parent = "#accordion2" href = "#collapseOne" >
  5. Tūemi Rōpū Tiango #1
  6. </a>
  7. </div>
  8. <div id = "collapseOne" class = "akordion-tinana tiango ki roto" >
  9. <div class = "akordion-roto" >
  10. Anim pariatur cliche...
  11. </div>
  12. </div>
  13. </div>
  14. <div class = "akordion-rōpū" >
  15. <div class = "akordion-upoko" >
  16. <a class = "accordion-toggle" data-toggle = "collapse" data-parent = "#accordion2" href = "#collapseTwo" >
  17. Tūemi Rōpū Tiango #2
  18. </a>
  19. </div>
  20. <div id = "collapseTwo" class = "accordion-body collapse" >
  21. <div class = "akordion-roto" >
  22. Anim pariatur cliche...
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. ...

Ka taea hoki e koe te whakamahi i te mono me te kore te tohu accordion. Hangaia he paatene takahuri te whakaroa me te tiango o tetahi atu huānga.

  1. < type button = "pātene" class = "btn btn-dater" data-toggle = "tiango" data-target = "#demo" >
  2. ngawari te tiango
  3. </pātene>
  4.  
  5. <div id = "demo" class = "collapse in" > </div>

Whakamahinga

Ma nga huanga raraunga

Tāpiri noa data-toggle="collapse"me te data-targetki te huānga ki te tautapa aunoa i te mana o te huānga tiango. Ka data-targetwhakaaetia e te huanga he kaikowhiri css hei hoatu i te tiango ki. Me tino taapiri te karaehe collapseki te huānga tiango. Mena kei te pirangi koe kia tuwhera taunoa, taapirihia te akomanga taapiri in.

Hei taapiri i te whakahaere roopu rite-akordion ki te mana tiango, taapirihia te huanga raraunga data-parent="#selector". Tirohia te demo kia kite i tenei mahi.

Ma te JavaScript

Whakahohe ā-ringa ki:

  1. $ ( ".collapse" ). tiango ()

Kōwhiringa

Ko nga whiringa ka taea te tuku ma nga huanga raraunga, JavaScript ranei. Mo nga huanga raraunga, apitihia te ingoa whiringa ki data-, penei i te data-parent="".

Ingoa momo taunoa whakaahuatanga
matua kaiwhiriwhiri teka Ki te kaikowhiri ka kati nga huānga tiango katoa i raro i te matua kua tohua ina whakaatuhia tenei mea tiango. (he rite ki te whanonga akoriona tuku iho)
takahuri boolean pono Ka takahuri i te huānga tiango i runga i te inoi

Nga tikanga

.collapse(kōwhiringa)

Ka whakahohe i to ihirangi hei huānga tiango. Ka whakaae ki nga whiringa whiriwhiri object.

  1. $ ( '#myCollapsible' ). tiango ({
  2. takahuri : teka
  3. })

.collapse('takahuri')

Ka takahuri i tetahi huānga tiango hei whakaatu, huna ranei.

.collapse('whakaatu')

Ka whakaatu i tetahi huānga tiango.

.collapse('huna')

Hunaia he huānga tiango.

Nga huihuinga

Ko te karaehe tiango a Bootstrap e whakaatu ana i etahi huihuinga mo te hono ki te mahi tiango.

Takahanga Whakaahuatanga
whakaatu Ka pupuhi tenei takahanga ina ka showkarangahia te aratuka tauira.
whakaaturia Ka puhia tenei takahanga ina kitea he huānga tiango ki te kaiwhakamahi (ka tatari kia oti nga whakawhitinga css).
huna Ka pupuhihia tenei kaupapa i te wa hidei kiia ai te tikanga.
huna Ka puhia tenei takahanga ina hunahia he huānga tiango mai i te kaiwhakamahi (ka tatari kia oti nga whakawhitinga css).
  1. $ ( '#myCollapsible' ). kei runga ( 'huna' , mahi () {
  2. // mahia tetahi mea…
  3. })

Tauira

He mono taketake, ngawari te whakaroa mo te hanga tere i nga momo upoko huatau me nga momo whakauru kuputuhi.

  1. < momo whakauru = "kuputuhi" raraunga-provide = "typeahead" >

Ka hiahia koe ki te tautuhi autocomplete="off"kia kore e puta nga tahua kaitirotiro taunoa ki runga i te maturuturunga iho o Bootstrap typeahead.


Whakamahinga

Ma nga huanga raraunga

Taapirihia nga huanga raraunga hei rehita i tetahi huānga me te mahi a te momotuhi e whakaatuhia ana i te tauira i runga ake nei.

Ma te JavaScript

Waea a ringa ki te upoko patopato me:

  1. $ ( '.typeahead' ). upoko patopato ()

Kōwhiringa

Ko nga whiringa ka taea te tuku ma nga huanga raraunga, JavaScript ranei. Mo nga huanga raraunga, apitihia te ingoa whiringa ki data-, penei i te data-source="".

Ingoa momo taunoa whakaahuatanga
puna huinga, mahi [ ] Ko te puna raraunga hei patai. He huinga aho, he mahi ranei. Ka tukuna te mahi e rua nga tohenga, ko te queryuara ki te mara whakauru me te processhokinga hoki. Ka taea te whakamahi i te taumahi ma te whakahoki tika i te puna raraunga, ma te tukutahi ranei ma te processtohenga kotahi a te waea hoki.
tūemi tau 8 Ko te maha o nga taonga hei whakaatu i te takaiho.
minRoa tau 1 Ko te roanga iti o te ahua e hiahiatia ana i mua i te whakaoho i nga whakaaro whakaoti aunoa
kaiwhakariterite mahi take koretake Ko te tikanga e whakamahia ana hei whakatau mena ka taurite tetahi patai ki tetahi mea. Ka whakaae ki te tohenga kotahi, ko te itemmea hei whakamatautau i te patai. Uru ki te uiui onāianei me te this.query. Whakahokia he boolean truemena he taurite te patai.
kaihoroi mahi ōrite tika,
take tairongo, take
tairongo
Tikanga i whakamahia hei kōmaka i nga hua whakaoti aunoa. Ka whakaae ki te tohenga kotahi items, a, kei a ia te whānuitanga o te tauira o te upoko patopato. Tohutoro te patai onāianei me te this.query.
kaiwhakahou mahi ka whakahoki mai i nga mea kua tohua Ko te tikanga i whakamahia hei whakahoki mai i nga mea kua tohua. Ka whakaae ki te tohenga kotahi, te itema kei a ia te whānuitanga o te tauira o te upoko patopato.
miramira mahi e whakaatu ana i nga whakataetae taunoa katoa Tikanga hei whakanui i nga hua whakaoti-aunoa. Ka whakaae ki te tohenga kotahi item, a, kei a ia te whānuitanga o te tauira o te upoko patopato. Me whakahoki html.

Nga tikanga

.typeahead(kōwhiringa)

Ka arataki i te whakaurunga me te upoko patopato.

Tauira

Ko te whakaterenga i te taha maui he whakaaturanga ora o te mono affix.


Whakamahinga

Ma nga huanga raraunga

Kia ngawari te taapiri i te whanonga piri ki tetahi huānga, taapiri noa data-spy="affix"ki te huānga e hiahia ana koe ki te tutei. Na ka whakamahi i nga waahi hei tautuhi i te wa e huri ai te titi o te huānga ki runga me te weto.

  1. <div data-spy = "affix" data-offset-top = "200" > ... </div>
Mahunga ake! Me whakahaere e koe te tuunga o te huānga kua titi me te whanonga o tona matua tonu. Kei te whakahaeretia te turanga e affix, affix-top, me affix-bottom. Kia mahara ki te tirotiro mo tetahi matua kua tiango pea ina whana te apiti i te wa e tango ana i nga ihirangi mai i te rere noa o te wharangi.

Ma te JavaScript

Karangatia te mono affix ma te JavaScript:

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

Kōwhiringa

Ko nga whiringa ka taea te tuku ma nga huanga raraunga, JavaScript ranei. Mo nga huanga raraunga, apitihia te ingoa whiringa ki data-, penei i te data-offset-top="200".

Ingoa momo taunoa whakaahuatanga
whakatiki tau | mahi | ahanoa 10 Pika hei whakatiki mai i te mata i te tatau i te tuunga o te panuku. Mēnā ka tukuna he tau kotahi, ka hoatu te whakakē ki te taha o runga me te taha maui. Ki te whakarongo ki te ahunga kotahi, ki te maha ranei o nga wehenga ahurei, homai noa he ahanoa offset: { x: 10 }. Whakamahia he mahi ina hiahia koe ki te whakarato hihiko i te utu (he whai hua mo etahi hoahoa aro).