JavaScript

Tisa swiphemu swa Bootstrap evuton’wini—sweswi hi 13 wa ti-plugin ta jQuery leti endleriweke wena.

Hi munhu hi xiyexe kumbe leyi hlengeletiweke

Tiplagi ti nga katsiwa hi toxe (hambi leswi tin’wana ti nga na ku titshega loku lavekaka), kumbe hinkwato hi nkarhi wun’we. Havumbirhi bya bootstrap.js na bootstrap.min.js swi na ti-plugin hinkwato eka fayili yin’we.

Swihlawulekisi swa datha

U nga tirhisa ti-plugin hinkwato ta Bootstrap ntsena hi ku tirhisa API ya markup handle ko tsala layini yin’we ya JavaScript. Leyi i API ya xiyimo xo sungula ya Bootstrap naswona yi fanele ku va ku ri ku tekela enhlokweni ka wena ko sungula loko u tirhisa plugin.

Loko swi vuriwa sweswo, eka swiyimo swin’wana swi nga ha navela ku tima ntirho lowu. Hikwalaho, hi tlhela hi nyika vuswikoti byo tshikisa API ya xihlawulekisi xa data hi ku susa swiendlakalo hinkwaswo eka miri namespaced hi `'data-api'`. Leswi swi languteka hi ndlela leyi:

  1. $ ( 'miri' ). ku tima ( '.data-api' ) .

Handle ka sweswo, ku kongomisa eka xiengetelo xo karhi, katsa ntsena vito ra xiengetelo tanihi ndhawu ya mavito swin’we ni ndhawu ya mavito ya data-api yo fana ni leyi:

  1. $ ( 'miri' ). off ( '.xitsundzuxo.data-api' ) .

API ya minongonoko

Hi tlhela hi tshemba leswaku u fanele ku kota ku tirhisa ti-plugin hinkwato ta Bootstrap ntsena hi ku tirhisa JavaScript API. Ti-API hinkwato ta mani na mani i tindlela tin’we, leti nga ni tinketana, naswona ti vuyisa nhlengeleto lowu endliweke hi wona.

  1. $ ( ".btn.khombo" ). button ( "ku cinca-cinca" ). addClass ( "mafurha" ) .

Maendlelo hinkwawo ya fanele ku amukela nchumu wa swihlawulekisi swa ku hlawula, ntambhu leyi kongomisaka eka ndlela yo karhi, kumbe ku nga ri na nchumu (leyi sungulaka xiengetelo hi mahanyelo ya xiviri):

  1. $ ( "#Modal ya mina" ). modal () // yi sunguriwile hi swihlawulekisi
  2. $ ( "#Modal ya mina" ). modal ({ keyboard : false }) // yi sunguriwile ku nga ri na khibhodi
  3. $ ( "#Modal ya mina" ). modal ( 'show' ) // yi sungula no vitana nkombiso hi ku hatlisa

Plugin yin'wana na yin'wana yi tlhela yi paluxa muaki wa yona wo ka wu nga swekiwanga eka nhundzu ya `Muaki`: $.fn.popover.Constructor. Loko u lava ku kuma xikombiso xo karhi xa plugin, xi vuyise hi ku kongoma eka elemente: $('[rel=popover]').data('popover').

Ku hava Ntwanano

Minkarhi yin’wana swa laveka ku tirhisa ti-plugin ta Bootstrap ni swivumbeko swin’wana swa UI. Eka swiyimo leswi, ku tlumbana ka ndhawu ya mavito ku nga humelela nkarhi wun’wana. Loko leswi swi humelela, u nga ha vitana .noConflicteka plugin leyi u lavaka ku tlherisela nkoka wa yona.

  1. var bootstrapXikomba-nkarhi = $ . fn . xikomba -nkarhi xa . noConflict () // vuyisa $.fn.button eka ntikelo lowu averiweke khale
  2. $ . fn . bootstrapBtn = bootstrapButton // nyika $().bootstrapBtn ntirho wa bootstrap

Swiendlakalo

Bootstrap yi nyika swiendlakalo swa ntolovelo eka swiendlo swo tala swo hlawuleka swa plugin. Hi ntolovelo, leswi swi ta hi xivumbeko xa xiendliwa lexi nga heriki na xiendliwa lexi hundzeke - laha xiendliwa lexi nga heriki (ex. show) xi pfuriwaka eku sunguleni ka xiendlakalo, naswona xivumbeko xa xona xa xiendliwa lexi hundzeke (ex. shown) xi hlohloteriwa loko xiendlo xi hetisisiwa.

Swiendlakalo hinkwaswo swa infinitive swi nyika ntirho wa preventDefault. Leswi swi nyika vuswikoti byo yimisa ku hetisisiwa ka xiendlo xi nga si sungula.

  1. $ ( '#Modal ya mina' ). on ( 'kombisa' , ntirho ( e ) {
  2. loko (! data ) vuyisa e . preventDefault () // yi yimisa modal ku kombisiwa
  3. }) .

Malunghana ni ku cinca-cinca

Ku kuma switandzhaku swo olova swa ku cinca, katsa bootstrap-transition.js kan’we etlhelo ka tifayela tin’wana ta JS. Loko u tirhisa bootstrap.js leyi hlengeletiweke (kumbe leyi hungutiweke) , a ku na xilaveko xo katsa leswi—se swi kona.

Tirhisa swiyimo

Swikombiso swi nga ri swingani swa xiengetelo xa ku cinca:

  • Ku rhetela kumbe ku fada eka ti modals
  • Ku fading out tithebhu
  • Ku nyamalala ka switsundzuxo
  • Tipheni ta carousel leti rhetaka

Swikombiso

Timodali ti olovisiwile, kambe ti cinca-cinca, switsundzuxo swa mbulavurisano leswi nga na ntirho wa le hansi lowu lavekaka na swihlawulekisi swo tlhariha.

Xikombiso xa xiyimo xa le henhla

Modal leyi humesiweke leyi nga na nhlokomhaka, miri, na sete ya swiendlo eka xiphemu xa le hansi.

  1. <div class = "ku nyamalala ka ku fihla ka modal" >
  2. <div class = "nhlokomhaka-ya-modal" >
  3. < muxaka wa buti = "button" class = "pfala" data-dismiss = "modal" aria-hidden = "ntiyiso" > &minkarhi; </button>
  4. <h3> Nhlokomhaka ya modali </h3>
  5. </div>
  6. <div class = "miri-wa-modal" >
  7. <p> Miri wun’we lowunene... </p>
  8. </div>
  9. <div class = "xihlamusela-marito xa xiyimo xa le hansi" >
  10. <a href = "#" tlilasi = "btn" > Pfala </a>
  11. <a href = "#" class = "btn btn-primary" > Hlayisa ku cinca </a>
  12. </div>
  13. </div>

Demo leyi hanyaka

Cinca modal hi ku tirhisa JavaScript hi ku tikhoma buti leyi nga laha hansi. Yi ta rhetela ehansi yi tlhela yi nyamalala ku suka ehenhla ka tluka.

  1. <!-- Batani yo pfuxa modal -->
  2. <a href = "#myModal" role = "button" class = "btn" data-toggle = "modal" > Sungula xivumbeko xa demo </a>
  3.  
  4. <!-- Modal -->
  5. <div id = "myModal" class = "modal hide fade" tabindex = "-1" xiphemu = "mbulavurisano" aria-labelledby = "myModalLabel" aria-hidden = "ntiyiso" >
  6. <div class = "nhlokomhaka-ya-modal" >
  7. < muxaka wa buti = "button" class = "pfala" data-dismiss = "modal" aria-hidden = "ntiyiso" > × </button>
  8. <h3 id = "myModalLabel" > Nhlokomhaka ya xivumbeko </h3>
  9. </div>
  10. <div class = "miri-wa-modal" >
  11. <p> Miri wun’we lowunene... </p>
  12. </div>
  13. <div class = "xihlamusela-marito xa xiyimo xa le hansi" >
  14. <button class = "btn" data-dismiss = "modal" aria-hidden = "ntiyiso" > Pfala </button>
  15. <button class = "btn btn-primary" > Hlayisa ku cinca </button>
  16. </div>
  17. </div>

Matirhiselo

Hi ku tirhisa swihlawulekisi swa data

Endla leswaku modal yi tirha handle ko tsala JavaScript. Seta data-toggle="modal"eka elemente ya controller, ku fana na button, xikan’we na a data-target="#foo"kumbe href="#foo"ku kongomisa modal yo karhi ku toggle.

  1. < muxaka wa buti = "button" data-toggle = "modal" data-target = "#myModal" > Sungula modal </button>

Hi ku tirhisa JavaScript

Fonela modal hi id myModalhi layini yin’we ya JavaScript:

  1. $ ( '#Modal ya mina' ). modal ( swihlawulekisi ) .

Swihlawulekisi

Swihlawulekisi swi nga hundzisiwa hi ku tirhisa swihlawulekisi swa data kumbe JavaScript. Eka swihlawulekisi swa datha, engetela vito ra xihlawuhlawu eka data-, tanihi le ka data-backdrop="".

Vito muxaka ku tlula nhlamuselo
xifaniso xa le ndzhaku xitsonga xitsonga ntiyiso Ku katsa na xiaki xa modal-backdrop. Handle ka sweswo, boxa staticeka backdrop leyi nga pfaliki modal eka click.
xikhiya xa xikhiya xitsonga xitsonga ntiyiso Ku pfala modal loko ku tshikileriwa escape key
kombisa xitsonga xitsonga ntiyiso Ku kombisa modal loko yi sunguriwa.
kule ndlela vunwa

Loko url ya le kule yi nyikiwile, nhundzu yi ta layicha hi ku tirhisa loadndlela ya jQuery naswona yi nghenisiwa eka .modal-body. Loko u tirhisa api ya data, u nga ha tirhisa hrefthegi hi ndlela yin’wana ku kombisa xihlovo xa le kule. Xikombiso xa leswi xi kombisiwile laha hansi:

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

Maendlelo

.modal(swihlawulekisi) .

Ku endla leswaku nhundzu ya wena yi tirha tanihi modal. Ku amukela swihlawulekisi swa ku hlawula object.

  1. $ ( '#Modal ya mina' ). modal ({
  2. xikhiya : mavunwa
  3. }) .

.modal('ku cinca-cinca') .

Hi voko u cinca-cinca modal.

  1. $ ( '#Modal ya mina' ). modal ( 'ku cinca-cinca' ) .

.modal('kombisa') .

Hi voko u pfula modal.

  1. $ ( '#Modal ya mina' ). modal ( 'kombisa' ) .

.modal('fihla') .

Hi voko u tumbeta modal.

  1. $ ( '#Modal ya mina' ). modal ( 'fihla' ) .

Swiendlakalo

Tlilasi ya modal ya Bootstrap yi paluxa swiendlakalo swi nga ri swingani swo khoma eka ntirho wa modal.

Nkhuvo Nhlamuselo
kombisa Xiendlakalo lexi xi pfurha hi ku hatlisa loko ku showvitaniwa ndlela ya xikombiso.
ku kombisiwile Xiendlakalo lexi xi duvuriwa loko modal yi endliwile yi vonaka eka mutirhisi (yi ta rindza ku cinca ka css ku hetisisiwa).
tumbela Xiendlakalo lexi xi duvuriwa hi ku hatlisa loko ndlela ya hidexikombiso yi vitaniwile.
tumbetile Xiendlakalo lexi xi duvuriwa loko modal yi hetile ku tumbetiwa eka mutirhisi (yi ta rindza ku cinca ka css ku hela).
  1. $ ( '#Modal ya mina' ). on ( 'ku fihliwile' , ntirho () {
  2. // endla swo karhi...
  3. }) .

Xikombiso eka navbar

Plugin ya ScrollSpy i ya ku pfuxeta hi ku tisungulela swikongomelo swa nav hi ku ya hi xiyimo xa scroll. Skrolela ndhawu leyi nga ehansi ka navbar ivi u hlalela ku cinca ka tlilasi leyi tirhaka. Swilo leswitsongo leswi nga ehansi swi ta kombisiwa na swona.

@mafurha

Ad leggings keytar, brunch id vutshila nkhuvo dolor labore. Pitchfork yr enim lo-fi va nga si xavisa qui. Tumblr timfanelo ta xikanyakanya xa purasi ku ya etafuleni whatever. Anim keffiyeh xitsonga xitsonga xitsonga xitsonga xitsonga. Velit seitan mcsweeney's xifaniso xa xiyindlwana 3 mpfundla n'weti irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui kumbexana a wu se twa hi vona et cardigan nkwama wa vutshembeki culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred xihlekiso biodiesel keffiyeh mutirhi wa mavoko ullamco consequat.

@mdo

Veniam marfa malebvu ya xikanyakanya, adipisicing fugiat velit malebvu ya pitchfork. Freegan malebvu aliqua cupidat mcsweeney ya vero. Cupidatat mune loko nisi, ea helvetica nulla carles. Tattooed cosby jesi lori swakudya, mcsweeney's quis non freegan vinyl. Lo-fi wes anderson +1 xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga. Carles non aesthetic ku endla vutiolori quis gentrify. Brooklyn adipisicing vutshila bya vutshila bya le xihundleni xa keytar deserunt.

n'we

Occaecat commodo xihlala xa xirhendzevutani. Fap vutshila byalwa deserunt xikanyakanya ea. Lomo timfanelo ta xikanyakanya adipisicing banh mi, velit ea sunt xiyimo lexi landzelaka locavore kofi ya masungulo yin’we eka magna veniam. Vutomi bya le henhla id vinyl, echo phaka consequat quis aliquip banh mi pitchfork. Vero VHS est ku hlantswa. Consectetur nisi DIY xikhwama xa murhumiwa lexitsongo. Cred ex eka, delectus consectetur fanny pack iphone leyi nga ta tshama nkarhi wo leha.

mbirhi

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 nkwama wa murhumiwa marfa yini na yini delectus lori ya swakudya. Sapiente synth id ya ku ehleketa. Locavore sed helvetica cliche irony, ti thundercats kumbexana a wu si twa hi tona consequat hoodie gluten-free lo-fi fap aliquip. Labore elit placeat va nga si xavisiwa, terry richardson proident brunch nesciunt quis cosby xisuti pariatur keffiyeh ut helvetica mutirhi wa mavoko. Cardigan craft biya seitan yi lunghekile velit. VHS chambray laboris xitsongwatsongwana xa nkarhinyana. Anim mollit minim commodo ullamco switsongwatsongwana swa ku dzindza ka tilo.


Matirhiselo

Hi ku tirhisa swihlawulekisi swa data

Ku engetela hi ku olova mahanyelo ya scrollspy eka ku famba ka wena ka topbar, engetela ntsena data-spy="scroll"eka elemente leyi u lavaka ku yi hlota (hi ntolovelo leyi yi ta va miri) na data-target=".navbar"ku hlawula leswaku u ta tirhisa nav yihi. U ta lava ku tirhisa scrollspy na .navxiphemu.

  1. <miri data-spy = "ku rhendzeleka" data-xikongomelo = ".navbar" > ... </miri>

Hi ku tirhisa JavaScript

Fonela scrollspy hi ku tirhisa JavaScript:

  1. $ ( '#navbar' ). xiphepherhele xa swiphepherhele () .
Tinhloko ta le henhla! Swihlanganisi swa Navbar swi fanele ku va na swikongomelo swa id leswi nga lulamisiwaka. Hi xikombiso, a yi <a href="#home">home</a>fanele yi fambisana ni nchumu lowu nga eka dom ku fana na <div id="home"></div>.

Maendlelo

.scrollspy('ku pfuxeta') .

Loko u tirhisa scrollspy hi ku fambisana na ku engetela kumbe ku susa swiaki eka DOM, u ta lava ku vitana ndlela yo pfuxeta ku fana na sweswo:

  1. $ ( '[data-spy="ku rhendzeleka"]' ). xin'wana na xin'wana ( ntirho () { .
  2. var $ nhlori = $ ( leswi ). scrollspy ( 'ku pfuxeta' ) .
  3. });

Swihlawulekisi

Swihlawulekisi swi nga hundzisiwa hi ku tirhisa swihlawulekisi swa data kumbe JavaScript. Eka swihlawulekisi swa datha, engetela vito ra xihlawuhlawu eka data-, tanihi le ka data-offset="".

Vito muxaka ku tlula nhlamuselo
offset nomboro 10. Tipikseli to offset kusuka ehenhla loko u hlayela xiyimo xa scroll.

Swiendlakalo

Nkhuvo Nhlamuselo
ku tirhisa Xiendlakalo lexi xi pfurha nkarhi wun’wana ni wun’wana loko nchumu lowuntshwa wu sungula ku tirhisiwa hi scrollspy.

Xikombiso xa tithebhu

Engetela ntirho wa thebhu wa xihatla, lowu cinca-cincaka ku cinca hi ku tirhisa tipheni ta swilo swa laha kaya, hambi ku ri hi ku tirhisa timenyu leti nga ehansi.

Raw denim kumbexana a wu se twa hi vona jean shorts Austin. Nesciunt tofu stumptown aliqua, ku basisiwa ka n’wini wa synth ya retro. Xikhovha xa malebvu xa nkarhinyana, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga. Xisuti xa cosby eu banh mi, qui irure terry richardson ex squid. Aliquip placeat xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga. Seitan aliquip quis cardigan swiambalo swa le Amerika, muxavisi wa nyama 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.


Matirhiselo

Endla leswaku tithebhu ta tithebhu ti tirha hi ku tirhisa JavaScript (thebhu yin’wana ni yin’wana yi lava ku tirhisiwa hi yoxe):

  1. $ ( '#Tab ya mina a' ). click ( ntirho ( e ) { .
  2. e . sivelaXihlawulekisi ();
  3. $ ( leswi ). tab ( 'kombisa' );
  4. }) .

U nga tirhisa tithebhu ha yin’we-yin’we hi tindlela to hlayanyana:

  1. $ ( '#Tab ya mina a[href="#profayile"]' ). tab ( 'kombisa' ); // Hlawula thebhu hi vito
  2. $ ( '#Tab ya mina a:yo sungula' ). tab ( 'kombisa' ); // Hlawula thebhu yo sungula
  3. $ ( '#Tab ya mina a:yo hetelela' ). tab ( 'kombisa' ); // Hlawula thebhu yo hetelela
  4. $ ( '#Tab ya mina li:eq(2) a' ). tab ( 'kombisa' ); // Hlawula thebhu ya vunharhu (0-indexed) .

Ku fungha swilo

U nga tirhisa ku famba-famba ka thebhu kumbe philisi handle ko tsala JavaScript yihi na yihi hi ku boxa ntsena data-toggle="tab"kumbe data-toggle="pill"eka elemente. Ku engetela titlilasi ta na eka thebhu navswi ta tirhisa xitayili xa thebhu ya Bootstrap.nav-tabsul

  1. <ul tlilasi = "nav nav-tithebhu" >
  2. <li><a href = "#ekaya" data-toggle = "thebhu" > Ekaya </a></li>
  3. <li><a href = "#profayile" data-toggle = "thebhu" > Xivumbeko </a></li>
  4. <li><a href = "#mahungu" data-toggle = "thebhu" > Mahungu </a></li>
  5. <li><a href = "#swiyimiso" data-toggle = "thebhu" > Switirhisiwa </a></li>
  6. </ul>

Maendlelo

$().thebhu ya kona

Ku tirhisa xiaki xa thebhu na xigwitsirisi xa nhundzu. Tab yi fanele ku va na a data-targetkumbe ku hrefkongomisa eka node ya xikhomela eka DOM.

  1. <ul class = "nav nav-tithebhu" id = "Tab ya mina" >
  2. <li class = "active" ><a href = "#kaya" > Ekaya </a></li>
  3. <li><a href = "#profayile" > Xivumbeko </a></li>
  4. <li><a href = "#mahungu" > Mahungu </a></li>
  5. <li><a href = "#swiyimiso" > Switirhisiwa </a></li>
  6. </ul>
  7.  
  8. <div class = "nhundzu ya thebhu" >
  9. <div class = "thebhu-pheni leyi tirhaka" id = "kaya" > ... </div>
  10. <div class = "thebhu-pheni" id = "phurofayili" > ... </div>
  11. <div class = "thebhu-pheni" id = "mahungu" > ... </div>
  12. <div class = "tab-pane" id = "swiletelo" > ... </div>
  13. </div>
  14.  
  15. <tsalwa>
  16. $ ( ntirho () { .
  17. $ ( '#Tab ya mina a:yo hetelela' ). tab ( 'kombisa' );
  18. }) .
  19. </script>

Swiendlakalo

Nkhuvo Nhlamuselo
kombisa Xiendlakalo lexi xi pfurha eka nkombiso wa thebhu, kambe thebhu leyintshwa yi nga si kombisiwa. Tirhisa event.targetna event.relatedTargetku kongomisa thebhu leyi tirhaka na thebhu leyi tirhaka ya khale (loko yi ri kona) hi ku landzelelana.
ku kombisiwile Xiendlakalo lexi xi pfurha eka nkombiso wa thebhu endzhaku ka loko thebhu yi kombisiwile. Tirhisa event.targetna event.relatedTargetku kongomisa thebhu leyi tirhaka na thebhu leyi tirhaka ya khale (loko yi ri kona) hi ku landzelelana.
  1. $ ( 'a [ku cinca-cinca ka data="thebhu"]' ). on ( 'ku kombisiwile' , ntirho ( e ) { .
  2. e . target // thebhu leyi tirhisiweke
  3. e . relatedTarget // thebhu ya khale
  4. }) .

Swikombiso

Ku hlohloteriwa hi jQuery.tipsy plugin ya kahle swinene leyi tsariweke hi Jason Frame; Switirhisiwa i vuhundzuluxeri lebyi pfuxetiweke, lebyi nga titshegangiki hi swifaniso, byi tirhisa CSS3 eka swifaniso leswi hanyaka, na data-attributes eka vuhlayiselo bya swihloko swa laha kaya.

Hi swivangelo swa matirhelo, xitirhisiwa na popover data-apis i opt in, leswi vulaka leswaku u fanele ku swi sungula hi wexe .

Hover ehenhla ka swihlanganisi leswi nga laha hansi ku vona switsundzuxo swa switirhisiwa:

Tight pants next level keffiyeh kumbexana a wu se swi twa. Xifaniso xa xivandla xa malebvu ya denim yo ka yi nga swekiwanga letterpress vegan messenger bag stumptown. Seitan ya le purasini ku ya etafuleni, mcsweeney’s fixie sustainable quinoa 8-bit swiambalo swa le Amerika swi na terry richardson vinyl chambray. Beard stumptown, ti-cardigan banh mi lomo ti- thundercat. Tofu biodiesel williamsburg marfa, mune loko mcsweeney ya basisa vegan chambray. A really ironic artisan whatever keytar , scenester purasi-ku-tafula banksy Austin twitter khoma freegan cred raw denim kofi ya masungulo yin’we ya xitsongwatsongwana.

Tindlela ta mune

Switsundzuxo swa switirhisiwa eka mintlawa ya swingheniso

Loko u tirhisa switsundzuxo swa switirhisiwa na ti-popover na mintlawa ya ku nghenisa ya Bootstrap, u ta boheka ku veka container(leyi tsariweke laha hansi) nhlawulo ku papalata switandzhaku leswi nga laviwiki.


Matirhiselo

Pfuxeta xitsundzuxo xa xitirhisiwa hi ku tirhisa JavaScript:

  1. $ ( '#xikombiso' ). xitsundzuxo xa switirhisiwa ( swihlawulekisi ) .

Swihlawulekisi

Swihlawulekisi swi nga hundzisiwa hi ku tirhisa swihlawulekisi swa data kumbe JavaScript. Eka swihlawulekisi swa datha, engetela vito ra xihlawuhlawu eka data-, tanihi le ka data-animation="".

Vito muxaka ku tlula nhlamuselo
ku endla swifaniso leswi hanyaka xitsonga xitsonga ntiyiso tirhisa ku cinca ka css fade eka xitirhisiwa
html xitsonga xitsonga vunwa Nghenisa html eka xitirhisiwa. Loko ku ri mavunwa, ndlela ya jquery textyi ta tirhisiwa ku nghenisa nhundzu eka dom. Tirhisa tsalwa loko u vilerisiwa hi nhlaselo wa XSS.
ku vekiwa ka swilo ntambhu ya xirhendzevutani | ntirho 'henhla' ndlela yo veka xitirhisiwa - ehenhla | ehansi | ximatsi | mfanelo
xihlawulekisi xa swilo ntambu vunwa Loko ku nyikiwile xihlawulekisi, swilo swa xitsundzuxo xa switirhisiwa swi ta nyikiwa swikongomelo leswi boxiweke.
xirhangi ntambhu ya xirhendzevutani | ntirho '' . nkoka wa xihloko xa xiviri loko thegi ya `title` yi nga ri kona
gwedla ntambu 'hover focus'. ndlela leyi xitirhisiwa xi pfuriwaka ha yona - tinya | hover | ku kongomisa | manyuwali. Xiya wena case pass trigger mutliple, ndhawu leyi hambanisiweke, tinxaka ta trigger.
hlwela nomboro | nchumu 0.

ku hlwela ku kombisa na ku tumbeta xitsundzuxo xa xitirhisiwa (ms) - a swi tirhi eka muxaka wa xihlohloteri xa manual

Loko nomboro yi nyikiwile, ku hlwela ku tirhisiwa eka havumbirhi bya ku fihla/kombisa

Xivumbeko xa nchumu i:delay: { show: 500, hide: 100 }

xigwitsirisi ntambhu ya xirhendzevutani | vunwa vunwa

Ku engetela xitsundzuxo xa xitirhisiwa eka elemente yo karhicontainer: 'body'

Tinhloko ta le henhla! Swihlawulekisi swa switsundzuxo swa switirhisiwa swa munhu hi xiyexe swi nga boxiwile hi ndlela yin’wana hi ku tirhisa swihlawulekisi swa datha.

Ku fungha swilo

  1. <a href = "#" data-toggle = "xitsundzuxo xa xitirhisiwa" title = "xitsundzuxo xo sungula xa xitirhisiwa" > hover ehenhla ka mina </a>

Maendlelo

$().xitsundzuxo xa switirhisiwa(swihlawulekisi) .

Ku khomanisa xitirhisiwa xa xitirhisiwa eka nhlengeleto wa swiaki.

.tooltip('kombisa') .

Ku paluxa xitsundzuxo xa xitirhisiwa xa elemente.

  1. $ ( '#xiaki' ). xitsundzuxo xa switirhisiwa ( 'kombisa' ) .

.tooltip('fihla') .

Ku fihla xitsundzuxo xa xitirhisiwa xa elemente.

  1. $ ( '#xiaki' ). xitsundzuxo xa switirhisiwa ( 'fihla' ) .

.tooltip('ku cinca-cinca') .

Ku cinca-cinca xitsundzuxo xa xitirhisiwa xa elemente.

  1. $ ( '#xiaki' ). xitsundzuxo xa switirhisiwa ( 'toggle' ) .

.tooltip('ku herisa') .

Ku tumbeta no herisa xitirhisiwa xa elemente.

  1. $ ( '#xiaki' ). tooltip ( 'ku herisa' ) .

Swikombiso

Engetelani swifunengeto leswitsongo swa swilo leswi nga endzeni, ku fana ni leswi nga eka iPad, eka elemente yihi na yihi yo veka rungula ra vumbirhi. Hover ehenhla ka button ku pfuxa popover. Swi lava leswaku Tooltip yi katsiwa.

Popover ya xiyimo xa le henhla

Ku ni swilo swa mune leswi u nga swi hlawulaka: leswi ringanisiweke ehenhla, exineneni, ehansi ni le ximatsi.

Popover ehenhla

Sed posuere consectetur est eka xiyimo xa le henhla. Aenean eu leo ​​quam. Ku khavisiwa ka pellentesque sem lacinia quam venenatis vestibulum.

Popover kunene

Sed posuere consectetur est eka xiyimo xa le henhla. Aenean eu leo ​​quam. Ku khavisiwa ka pellentesque sem lacinia quam venenatis vestibulum.

Popover ehansi

Sed posuere consectetur est eka xiyimo xa le henhla. Aenean eu leo ​​quam. Ku khavisiwa ka pellentesque sem lacinia quam venenatis vestibulum.

Popover u fambile

Sed posuere consectetur est eka xiyimo xa le henhla. Aenean eu leo ​​quam. Ku khavisiwa ka pellentesque sem lacinia quam venenatis vestibulum.

Ku hava markup leyi kombisiweke tanihi ti-popover leti endliweke ku suka eka JavaScript na nhundzu endzeni ka dataxihlawulekisi.

Demo leyi hanyaka

Tindlela ta mune


Matirhiselo

Endla leswaku ti-popovers ti tirha hi ku tirhisa JavaScript:

  1. $ ( '#xikombiso' ). popover ( swihlawulekisi ) .

Swihlawulekisi

Swihlawulekisi swi nga hundzisiwa hi ku tirhisa swihlawulekisi swa data kumbe JavaScript. Eka swihlawulekisi swa datha, engetela vito ra xihlawuhlawu eka data-, tanihi le ka data-animation="".

Vito muxaka ku tlula nhlamuselo
ku endla swifaniso leswi hanyaka xitsonga xitsonga ntiyiso tirhisa ku cinca ka css fade eka xitirhisiwa
html xitsonga xitsonga vunwa Nghenisa html eka popover. Loko ku ri mavunwa, ndlela ya jquery textyi ta tirhisiwa ku nghenisa nhundzu eka dom. Tirhisa tsalwa loko u vilerisiwa hi nhlaselo wa XSS.
ku vekiwa ka swilo ntambhu ya xirhendzevutani | ntirho 'mfanelo' ndlela yo veka popover - ehenhla | ehansi | ximatsi | mfanelo
xihlawulekisi xa swilo ntambu vunwa loko ku nyikiwile xihlawulekisi, swilo swa xitsundzuxo xa switirhisiwa swi ta nyikiwa swikongomelo leswi boxiweke
gwedla ntambu 'click'. ndlela leyi popover yi sungulaka ha yona - click | hover | ku kongomisa | manyuwali
xirhangi ntambhu ya xirhendzevutani | ntirho '' . nkoka wa xihloko xa xiviri loko xihlawulekisi xa `title` xi nga ri kona
vundzeni ntambhu ya xirhendzevutani | ntirho '' . nkoka wa nhundzu ya xiviri loko xihlawulekisi xa `data-content` xi nga ri kona
hlwela nomboro | nchumu 0.

ku hlwela ku kombisa na ku tumbeta popover (ms) - a swi tirhi eka muxaka wa manual trigger

Loko nomboro yi nyikiwile, ku hlwela ku tirhisiwa eka havumbirhi bya ku fihla/kombisa

Xivumbeko xa nchumu i:delay: { show: 500, hide: 100 }

xigwitsirisi ntambhu ya xirhendzevutani | vunwa vunwa

Ku engetela popover eka elemente yo karhicontainer: 'body'

Tinhloko ta le henhla! Swihlawulekisi swa ti-popovers ha yin’we-yin’we swi nga boxiwile hi ndlela yin’wana hi ku tirhisa swihlawulekisi swa datha.

Ku fungha swilo

Hi swivangelo swa matirhelo, Tooltip na Popover data-apis swi hlawula ku nghena Loko u lava ku swi tirhisa ntsena boxa nhlawulo wa xihlawulekisi.

Maendlelo

$().popover(swihlawulekisi) .

Ku sungula ti-popovers ta nhlengeleto wa swiaki.

.popover('kombisa') .

Ku paluxa an elements popover.

  1. $ ( '#xiaki' ). popover ( 'kombisa' ) .

.popover('fihla') .

Ku tumbeta an elements popover.

  1. $ ( '#xiaki' ). popover ( 'fihla' ) .

.popover('ku cinca-cinca') .

Ku cinca-cinca ka swiaki swa popover.

  1. $ ( '#xiaki' ). popover ( 'ku cinca-cinca' ) .

.popover('ku herisa') .

Ku tumbeta no herisa popover ya element.

  1. $ ( '#xiaki' ). popover ( 'ku herisa' ) .

Xikombiso xa switsundzuxo

Engetela ntirho wo hlongola eka marungula hinkwawo ya xitsundzuxo hi xiengetelo lexi.

Guacamole yo kwetsima! Best check yo self, a wu languteki kahle ngopfu.

Oh snap! U kume xihoxo!

Cinca leswi na leswiya ivi u ringeta nakambe. Duis mollis, est non commodo luctus, nisi erat xirho xa xirhendzevutani, xitsongwatsongwana xa xirhendzevutani xa xirhendzevutani. Cras mattis consectetur purus yitshama eka fermentum.

Teka goza leri Kumbe u endla leswi


Matirhiselo

Endla leswaku ku hlongoriwa ka xitsundzuxo ku tirha hi ku tirhisa JavaScript:

  1. $ ( ".xitsundzuxo" ). xitsundzuxo () .

Ku fungha swilo

Ntsena engetela data-dismiss="alert"eka buti ya wena yo pfala ku nyika hi ku tisungulela ntirho wa ku pfala wa xitsundzuxo.

  1. <a class = "pfala" data-dismiss = "xitsundzuxo" href = "#" > &minkarhi; </a>

Maendlelo

$().xitsundzuxo() .

Pfuxeta switsundzuxo hinkwaswo hi ntirho wa le kusuhi. Ku endla leswaku switsundzuxo swa wena swi hanya loko swi pfariwile, tiyisisa leswaku swi na .fadena .intlilasi leyi se yi tirhisiweke eka swona.

.alert('pfala') .

Ku pfala xitsundzuxo.

  1. $ ( ".xitsundzuxo" ). xitsundzuxo ( 'pfala' ) .

Swiendlakalo

Tlilasi ya xitsundzuxo ya Bootstrap yi paluxa swiendlakalo swi nga ri swingani swo khoma eka ntirho wa xitsundzuxo.

Nkhuvo Nhlamuselo
pfala Xiendlakalo lexi xi pfurha hi ku hatlisa loko ku closevitaniwa ndlela ya xikombiso.
ku pfariwile Xiendlakalo lexi xi pfuriwa loko xitsundzuxo xi pfariwile (xi ta rindza ku cinca ka css ku hela).
  1. $ ( '#xitsundzuxo xa mina' ). bind ( 'ku pfariwile' , ntirho () {
  2. // endla swo karhi...
  3. }) .

Swikombiso swa matirhiselo

Endla swo tala hi swikomba-nkarhi. Vulawuri bya swikomba-nkarhi kumbe ku tumbuluxa mintlawa ya swikomba-nkarhi swa swiphemu swo tala swo fana na tibarhi ta switirhisiwa.

Stateful

Engetela data-loading-text="Loading..."ku tirhisa xiyimo xo layicha eka buti.

  1. < muxaka wa buti = "button" class = "btn btn-primary" data-loading-text = "Ku layicha..." > Xiyimo xa ku layicha </button>

Toggle yin’we

Engetela data-toggle="button"ku endla leswaku ku cinca-cinca ku tirha eka buti yin’we.

  1. < muxaka wa buti = "button" class = "btn btn-primary" data-toggle = "button" > Ku cinca-cinca kun'we </button>

Bokisi ro kambela

Engetelani data-toggle="buttons-checkbox"ku cinca-cinca ka xitayili xa bokisi ro kambela eka btn-group.

  1. <div class = "btn-group" data-toggle = "swikomba-ndlela-bokisi ro kambela" >
  2. < muxaka wa buti = "button" class = "btn btn-primary" > Ximatsi </button>
  3. < muxaka wa buti = "button" class = "btn btn-primary" > Xikarhi </button>
  4. < muxaka wa buti = "button" class = "btn btn-primary" > Xinene </button>
  5. </div>

Xiya-ni-moya

Engetelani data-toggle="buttons-radio"ku cinca-cinca ka xitayili xa radio eka btn-group.

  1. <div class = "btn-ntlawa" data-toggle = "swikomba-ndlela-radio" >
  2. < muxaka wa buti = "button" class = "btn btn-primary" > Ximatsi </button>
  3. < muxaka wa buti = "button" class = "btn btn-primary" > Xikarhi </button>
  4. < muxaka wa buti = "button" class = "btn btn-primary" > Xinene </button>
  5. </div>

Matirhiselo

Endla leswaku swikomba-nkarhi swi tirha hi ku tirhisa JavaScript:

  1. $ ( '.nav-tithebhu' ). xikomba -nkarhi () .

Ku fungha swilo

Swihlawulekisi swa datha i swa nkoka eka xiengetelo xa buti. Languta khodi ya xikombiso laha hansi eka tinxaka to hambana ta swimaki.

Swihlawulekisi

Hava

Maendlelo

$().button('ku cinca-cinca') .

Ku cinca-cinca xiyimo xa push. Yi nyika button xivumbeko xa leswaku yi tirhisiwile.

Tinhloko ta le henhla! U nga endla leswaku auto toggling ya button yi tirha hi ku tirhisa data-toggleattribute.
  1. < muxaka wa buti = "button" class = "btn" data-toggle = "button" > ... </button>

$().button('ku layicha') .

Seta xiyimo xa buti eka ku layicha - yi tshikisa buti na ku cincana tsalwa eka ku layicha tsalwa. Ku layicha tsalwa ku fanele ku hlamuseriwa eka elemente ya buti hi ku tirhisa xihlawulekisi xa datha data-loading-text.

  1. < muxaka wa buti = "button" class = "btn" data-loading-text = "ku layicha swilo..." > ... </button>
Tinhloko ta le henhla! Firefox yi phikelela xiyimo lexi nga tirhiki eka ku layicha ka matluka hinkwawo . Ntlhantlho wa leswi i ku tirhisa autocomplete="off".

$().button('seta nakambe') .

Ku tlherisela xiyimo xa buti - cinca tsalwa eka tsalwa ra masungulo.

$().button(ntambhu) .

Yi tlherisela xiyimo xa buti - yi cincana tsalwa eka xiyimo xihi na xihi xa tsalwa lexi hlamuseriweke hi datha.

  1. < muxaka wa buti = "button" class = "btn" data-complete-text = "ku hetisiwile!" > ... </button> leyi nga kona
  2. <tsalwa>
  3. $ ( '.btn' ). button ( 'ku hetiseka' ) .
  4. </script>

Hi

Kuma switayele swa le hansi na nseketelo lowu cinca-cincaka wa swiphemu leswi pfalaka ku fana na ti-accordion na ku famba-famba.

* Swi lava leswaku ku katsiwa plugin ya Transitions.

Xikombiso xa accordion

Hi ku tirhisa plugin ya collapse, hi ake xitirhisiwa xo olova xa xitayili xa accordion:

Anim pariatur cliche reprehenderit, enim eiusmod vutomi bya le henhla accusamus terry richardson ad ximanga. 3 mpfundla wa n’weti officia aute, non cupidat xikanyakanya dolor brunch. Lori ya swakudya quinoa nesciunt laborum eiusmod. Brunch 3 mpfundla n’weti tempo, sunt aliqua veka xinyenyana eka yona squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, ntirho wa vutshila bya biya wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur muxanisi wa nyama vice lomo. Leggings occaecat craft beer purasi-ku-tafula, raw denim aesthetic synth nesciunt kumbexana a wu si twa hi vona accusamus labore sustainable VHS.
Anim pariatur cliche reprehenderit, enim eiusmod vutomi bya le henhla accusamus terry richardson ad ximanga. 3 mpfundla wa n’weti officia aute, non cupidat xikanyakanya dolor brunch. Lori ya swakudya quinoa nesciunt laborum eiusmod. Brunch 3 mpfundla n’weti tempo, sunt aliqua veka xinyenyana eka yona squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, ntirho wa vutshila bya biya wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur muxanisi wa nyama vice lomo. Leggings occaecat craft beer purasi-ku-tafula, raw denim aesthetic synth nesciunt kumbexana a wu si twa hi vona accusamus labore sustainable VHS.
Anim pariatur cliche reprehenderit, enim eiusmod vutomi bya le henhla accusamus terry richardson ad ximanga. 3 mpfundla wa n’weti officia aute, non cupidat xikanyakanya dolor brunch. Lori ya swakudya quinoa nesciunt laborum eiusmod. Brunch 3 mpfundla n’weti tempo, sunt aliqua veka xinyenyana eka yona squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, ntirho wa vutshila bya biya wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur muxanisi wa nyama vice lomo. Leggings occaecat craft beer purasi-ku-tafula, raw denim aesthetic synth nesciunt kumbexana a wu si twa hi vona accusamus labore sustainable VHS.
  1. <div class = "akhodiyoni" id = "akhodiyoni2" >
  2. <div class = "ntlawa-wa-accordion" >
  3. <div class = "nhlokomhaka ya accordion" >
  4. <a class = "accordion-toggle" data-toggle = "ku wisa" mutswari wa data = "#akhodiyoni2" href = "#ku wisaYin'we" >
  5. Nchumu wa Ntlawa lowu Pfuxetiwaka #1
  6. </a>
  7. </div>
  8. <div id = "collapseOne" class = "ku wa ka miri wa accordion eka" >
  9. <div class = "akhodiyoni-ya le ndzeni" >
  10. Anim pariatur xitsonga xitsonga...
  11. </div>
  12. </div>
  13. </div>
  14. <div class = "ntlawa-wa-accordion" >
  15. <div class = "nhlokomhaka ya accordion" >
  16. <a class = "accordion-toggle" data-toggle = "ku wisa" data-mutswari = "#akhodiyoni2" href = "#ku wisaTwo" >
  17. Nchumu wa Ntlawa lowu Pfuxetiwaka #2
  18. </a>
  19. </div>
  20. <div id = "collapseTwo" class = "ku wa ka miri wa accordion" >
  21. <div class = "akhodiyoni-ya le ndzeni" >
  22. Anim pariatur xitsonga xitsonga...
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. ...

U nga ha tlhela u tirhisa plugin handle ka xikombiso xa accordion. Endla leswaku buti yi cinca-cinca ku andlala ni ku wa ka elemente yin’wana.

  1. < muxaka wa buti = "button" class = "btn btn-khombo" data-toggle = "ku wa" data-xikongomiso = "#demo" >
  2. ku olova loku pfotlosaka
  3. </button>
  4.  
  5. <div id = "demo" class = "ku wa eka" > ... </div>

Matirhiselo

Hi ku tirhisa swihlawulekisi swa data

Ntsena engetela data-toggle="collapse"na a data-targeteka elemente ku avela hi ku tisungulela vulawuri bya elemente leyi nga pfaleriwaka. Xihlawulekisi data-targetxi amukela xihlawulekisi xa css ku tirhisa ku wisa eka xona. Tiyiseka leswaku u engetela tlilasi collapseeka xiaki lexi nga pfaleriwaka. Loko u lava leswaku yi pfuleka hi ku tiyimisela, engetela tlilasi leyi engetelekeke in.

Ku engetela vulawuri bya ntlawa byo fana na accordion eka vulawuri lebyi pfalekaka, engetela xihlawulekisi xa data data-parent="#selector". Languta eka demo ku vona leswi swi ri karhi swi tirha.

Hi ku tirhisa JavaScript

Endla leswaku swi tirha hi voko hi:

  1. $ ( ".ku tshoveka" ). ku wa () .

Swihlawulekisi

Swihlawulekisi swi nga hundzisiwa hi ku tirhisa swihlawulekisi swa data kumbe JavaScript. Eka swihlawulekisi swa datha, engetela vito ra xihlawuhlawu eka data-, tanihi le ka data-parent="".

Vito muxaka ku tlula nhlamuselo
mutswari xihlawulekisi xa swilo vunwa Loko selector kutani swiaki hinkwaswo leswi pfaleriwaka ehansi ka mutswari loyi a boxiweke swi ta pfala loko nchumu lowu wu pfaleriwaka wu kombisiwa. (ku fana ni mahanyelo ya ndhavuko ya accordion) .
ku cinca-cinca xitsonga xitsonga ntiyiso Ku cinca-cinca xiaki lexi nga pfaleriwaka eka ku vitaniwa

Maendlelo

.collapse(swihlawulekisi) .

Ku endla leswaku nhundzu ya wena yi tirha tanihi xiaki lexi nga pfaleriwaka. Ku amukela swihlawulekisi swa ku hlawula object.

  1. $ ( '#swi nga pfaleriwa hi mina' ). ku wa ({
  2. toggle : mavunwa
  3. }) .

.collapse('ku cinca-cinca') .

Ku cinca-cinca xiaki lexi nga pfaleriwaka ku ya eka lexi kombisiweke kumbe lexi fihliweke.

.collapse('kombisa') .

Ku kombisa xiaki lexi nga tshovekaka.

.collapse('fihla') .

Ku tumbeta xiaki lexi nga tshovekaka.

Swiendlakalo

Tlilasi ya ku wa ya Bootstrap yi paluxa swiendlakalo swi nga ri swingani swo khoma eka ntirho wa ku wa.

Nkhuvo Nhlamuselo
kombisa Xiendlakalo lexi xi pfurha hi ku hatlisa loko ku showvitaniwa ndlela ya xikombiso.
ku kombisiwile Xiendlakalo lexi xi duvuriwa loko xiaki xa ku wa xi endliwile xi vonaka eka mutirhisi (xi ta rindza ku cinca ka css ku hetisisiwa).
tumbela Xiendlakalo lexi xi duvuriwa hi ku hatlisa loko hidendlela yi vitaniwile.
tumbetile Xiendlakalo lexi xi duvuriwa loko elemente ya collapse yi fihliwile eka mutirhisi (yi ta rindza ku cinca ka css ku hetisisiwa).
  1. $ ( '#swi nga pfaleriwa hi mina' ). on ( 'ku fihliwile' , ntirho () {
  2. // endla swo karhi...
  3. }) .

Xikombiso

Plugin ya xisekelo, leyi andlariweke hi ku olova yo hatlisa ku tumbuluxa ti-typeahead to saseka hi ku nghenisa tsalwa ra fomo rihi na rihi.

  1. < muxaka wa ku nghenisa = "tsalwa" data-provide = "typeahead" >

U ta lava ku veka autocomplete="off"ku sivela timenyu ta xihlamusela-marito xa xiviri ku humelela ehenhla ka Bootstrap typeahead dropdown.


Matirhiselo

Hi ku tirhisa swihlawulekisi swa data

Engetela swihlawulekisi swa datha ku tsarisa elemente leyi nga na ntirho wa typeahead tanihilaha swi kombisiweke hakona eka xikombiso lexi nga laha henhla.

Hi ku tirhisa JavaScript

Fonela typeahead hi voko hi:

  1. $ ( '.ku thayipa emahlweni' ). ku thayipa emahlweni () .

Swihlawulekisi

Swihlawulekisi swi nga hundzisiwa hi ku tirhisa swihlawulekisi swa data kumbe JavaScript. Eka swihlawulekisi swa datha, engetela vito ra xihlawuhlawu eka data-, tanihi le ka data-source="".

Vito muxaka ku tlula nhlamuselo
xihlovo array, ntirho [ ] . Xihlovo xa data xo vutisa ku lwisana na xona. Ku nga ha va ku ri nxaxamelo wa tintambhu kumbe ntirho. Ntirho wu hundzisiwa ti arguments timbirhi, queryvalue eka input field na processcallback. Ntirho wu nga tirhisiwa hi ku fambisana hi ku tlherisela xihlovo xa datha hi ku kongoma kumbe hi ku nga fambisani hi ku tirhisa processargument yin’we ya callback.
swilo nomboro 8. Nhlayo ya max ya swilo leswi nga ta kombisiwa eka dropdown.
minKu leha nomboro 1. Ku leha ka ximunhuhatwa xa le hansi loku lavekaka ku nga si sungula swiringanyeto swa autocomplete
muhlanganisi wa swilo ntirho ku nga ri na vuxiyaxiya eka maletere lamakulu Ndlela leyi tirhisiwaka ku kumisisa loko xivutiso xi fambisana ni nchumu wo karhi. Amukela njhekanjhekisano wun’we, itemlowu ku nga ta ringeta xivutiso ku lwisana na wona. Fikelela xivutiso xa sweswi hi this.query. Vuyisa boolean trueloko xivutiso xi ri ku fambisana.
muhleri ​​wa swilo ntirho ku fambisana loku kongomeke,
ku va ni maletere lamakulu, ku nga ri na
maletere lamakulu
Ndlela leyi tirhisiwaka ku hlela mimbuyelo ya autocomplete. Amukela njhekanjhekisano wun’we itemsnaswona yi na xikalo xa xikombiso xa typeahead. Kombetela xivutiso xa sweswi hi this.query.
mupfuxeti wa swilo ntirho yi vuyisa nchumu lowu hlawuriweke Ndlela leyi tirhisiwaka ku tlherisela nchumu lowu hlawuriweke. Amukela njhekanjhekisano wun’we, the itemna yi na xikalo xa xikombiso xa typeahead.
xihlawulekisi xa swilo ntirho yi kombisa ku fambisana hinkwako ka ntolovelo Ndlela leyi tirhisiwaka ku kombisa mimbuyelo ya autocomplete. Amukela njhekanjhekisano wun’we itemnaswona yi na xikalo xa xikombiso xa typeahead. Swi fanele ku vuyisa html.

Maendlelo

.typeahead(swihlawulekisi) .

Ku sungula ku nghenisa hi typeahead.

Xikombiso

Ku famba-famba loku nga eximatsini i demo leyi hanyaka ya xiengetelo xa xiengetelo.


Matirhiselo

Hi ku tirhisa swihlawulekisi swa data

Ku engetela mahanyelo ya affix hi ku olova eka elemente yihi na yihi, engetela ntsena data-spy="affix"eka elemente leyi u lavaka ku yi hlota. Kutani tirhisa ti-offset ku hlamusela leswaku u fanele u cinca rini ku pfula ni ku tima ku pini ka elemente.

  1. <div data-spy = "xiengetelo" data-offset-ehenhla = "200" > ... </div>
Tinhloko ta le henhla! U fanele ku lawula xiyimo xa elemente leyi pinned na mahanyelo ya mutswari wa yona wa le kusuhi. Xiyimo xi lawuriwa hi affix, affix-top, na affix-bottom. Tsundzuka ku kambela mutswari loyi a nga ha tshovekaka loko xiengetelo xi nghena tanihi leswi xi susaka nhundzu eka ku khuluka ka ntolovelo ka tluka.

Hi ku tirhisa JavaScript

Fonela xiengetelo xa xiengetelo hi ku tirhisa JavaScript:

  1. $ ( '#navbar' ). xiengetelo xa () .

Swihlawulekisi

Swihlawulekisi swi nga hundzisiwa hi ku tirhisa swihlawulekisi swa data kumbe JavaScript. Eka swihlawulekisi swa datha, engetela vito ra xihlawuhlawu eka data-, tanihi le ka data-offset-top="200".

Vito muxaka ku tlula nhlamuselo
offset nomboro | ntirho | nchumu 10. Tipikseli to offset kusuka eka xikirini loko u hlayela xiyimo xa scroll. Loko ku nyikiwa nomboro yin’we, offset yi ta tirhisiwa eka matlhelo ya le henhla na ya ximatsi. Ku yingisela nkongomiso wun’we, kumbe ti-offset to tala to hlawuleka, nyika ntsena nchumu offset: { x: 10 }. Tirhisa ntirho loko u lava ku nyika hi ndlela leyi cinca-cincaka offset (leswi pfunaka eka tipulani tin’wana leti hlamulaka).