JaavaScript

Qaamolee Bootstrap jireenyatti fidi-amma 13 amala jQuery plugins waliin.

Dhuunfaa ykn qindaa’ee

Ijaarsi dhuunfaan hammatamuu danda'u (tokko tokko hirkattummaa barbaadan ta'us), ykn hunda yeroo tokkotti. Bootstrap.js fi bootstrap.min.js lamaan isaanii faayilii tokko keessatti ifteessitoota hunda of keessaa qabu.

Amaloota deetaa

Sarara JaavaScript tokko osoo hin barreessiin pilaaginoota Bootstrap hunda karaa API mallattoo qulqulluu ta'een fayyadamuu dandeessa. Kun API sadarkaa jalqabaa Bootstrap yoo ta'u yeroo plugin fayyadamtu yaada kee isa jalqabaa ta'uu qaba.

Kana jechuun, haala tokko tokko keessatti dalagaa kana dhaamsuun barbaachisaa ta'uu danda'a. Kanaafuu, taateewwan hunda maqaa qaama irratti `'data-api'` waliin addaan baafaman irratti hiikuudhaan API amaloota deetaa hanqisuuf dandeettii ni kennina. Kunis akkana fakkaata:

  1. $ ( 'qaama' ). off ( '.daataa-api' ) .

Akka filannootti, ifteessaa murtaa'e irratti xiyyeeffachuuf, maqaa ifteessaa akka iddoo maqaatti iddoo maqaa deetaa-api waliin akkasitti qofa hammachuu:

  1. $ ( 'qaama' ). off ( '.akeekkachiisa.daataa-api' ) .

API sagantaa

Akkasumas, Bootstrap plugins hunda karaa JavaScript API qulqulluu ta'een fayyadamuu danda'uu qabdu jennee amanna. APIwwan uummataa hundi malawwan tokko, sansalata qaban, fi walitti qabama irratti tarkaanfii fudhatame deebisu.

  1. $ ( ".btn.balaa" ). button ( "jijjiirraa" ). addClass ( "cophaa" ) .

Malleen hundi wanta filannoowwan filannoo, tarree mala murtaa'e irratti xiyyeeffatu, ykn homaa hin qabne (kan amala durtii waliin ifteessituu jalqabu) fudhachuu qabu:

  1. $ ( "#Moodaalii koo" ). modal () // durtii waliin jalqabame
  2. $ ( "#Moodaalii koo" ). modal ({ keyboard : soba }) // furtuu tokko malee jalqabame
  3. $ ( "#Moodaalii koo" ). modal ( 'show' ) // agarsiisa battalumatti jalqaba fi waama

Tokkoon tokkoon ifteessaa akkasumas ijaarsa isaa raw qabeentaa `Ijaarsa` irratti saaxilaa: $.fn.popover.Constructor. Yoo fakkeenya ifteessaa murtaa'e argachuu barbaadde, kallattiin elementii irraa fudhadhu: $('[rel=popover]').data('popover').

Waldhabdee Hin Qabu

Yeroo tokko tokko bootstrap plugins ui frameworks biroo wajjin fayyadamuun barbaachisaadha. Haalota kanneen keessatti, darbee darbee walitti bu'iinsi iddoo maqaa uumamuu danda'a. Yoo kun ta'e, .noCoflictpilaaginii gatii isaa deebisuu barbaaddu bilbiluu dandeessa.

  1. var Qabduu bootstrap = $ . fn jechuun . button . noConflict () // $.fn.button gara gatii duraan ramadameetti deebisa
  2. $ . fn jechuun . bootstrapBtn = bootstrapButton // $().bootstrapBtn dalagaa bootstrap kennuu

Taateewwan

Bootstrap taateewwan amala gochoota addaa plugin irra caalaan isaaniif kenna. Walumaagalatti, kunniin bifa xumura hin qabnee fi gocha darbeen dhufu - bakka dhuma hin qabne (fkn show) jalqaba taatee tokkoo irratti kaka’u, fi bifa gocha isaa darbe (fk. shown) xumura gocha tokkoo irratti kaka’u.

Taateewwan dhuma hin qabne hundi dalagaa preventDefault ni kennu. Kunis dandeettii raawwii gocha tokkoo osoo hin jalqabin dhaabuu kenna.

  1. $ ( '#Moodaalii koo' ). on ( 'agarsiisi' , faankishinii ( e ) { .
  2. yoo ( ! deetaa ) e . preventDefault () // moodaalii akka hin agarsiifamne dhaaba
  3. }) .

Waa'ee ce'umsaa

Bu'aa ce'umsaa salphaadhaaf, bootstrap-transition.js al tokko faayilii JS kanneen biroo cinatti dabali. Yoo bootstrap.js qindaa'e (ykn xiqqaate) fayyadamaa jirta ta'e, kana hammachuun hin barbaachisu—dursee jira.

Fayyadama keesii

Fakkeenyota muraasni pilaaginii ce'umsaa:

  • Moodaalota keessatti islaayidii ykn fading
  • Caancalawwan fading out ta'an
  • Fading out akeekkachiisa
  • Qaaqa karooseelii kan lilmoo'u

Fakkeenyaaf

Moodaalonni qajeeloo, garuu jijjiiramaa, qaaqa gaaffiiwwan dalagaa xiqqaa barbaadamu fi durtii ismaartii qaban.

Fakkeenya istaatiksii

Moodaalii agarsiifame mataduree, qaama, fi tuuta gochoota jalaqaba keessatti.

  1. <div class = "fade dhoksaa moodaalii" >
  2. <div class = "mataduree-moodaalii" >
  3. < gosa qaree = "button" class = "cufi" data-dismiss = "moodaalii" aria-dhoksaa = "dhugaa" > &yeroo; </button> jedhu
  4. <h3> Mata duree moodaalii </h3>
  5. </div> jechuun ni danda’ama
  6. <div class = "qaama-moodaalii" >
  7. <p> Qaama gaarii tokko... </p>
  8. </div> jechuun ni danda’ama
  9. <div class = "moodaalii-jalqabaa" >
  10. <a href = "#" gita = "btn" > Cufi </a>
  11. <a href = "#" class = "btn btn-primary" > Jijjiiramoota saagi </a>
  12. </div> jechuun ni danda’ama
  13. </div> jechuun ni danda’ama

Deemoo kallattiin

Qabduu armaan gadii cuqaasuun moodaalii tokko karaa JaavaScript jijjiiri. Innis gadi siqee gubbaa fuula irraa ni fade in ta'a.

  1. <!-- Qabduu moodaalii kakaasuuf -->
  2. <a href = "#myModal" gahee = "button" class = "btn" data-toggle = "moodaalii" > Moodaala demoo jalqabi </a>
  3.  
  4. <!-- Moodaalii -->
  5. <div id = "myModal" class = "moodaalii dhoksuu fade" tabindex = "-1" gahee = "qaaqa" aria-labelledby = "myModalLabel" aria-dhokfame = "dhugaa" >
  6. <div class = "mataduree-moodaalii" >
  7. < gosa qaree = "qaree" gita = "cufi" data-dismiss = "moodaalii" aria-dhoksaa = "dhugaa" > × </button>
  8. <h3 id = "myModalLabel" > Mata duree moodaalii </h3>
  9. </div> jechuun ni danda’ama
  10. <div class = "qaama-moodaalii" >
  11. <p> Qaama gaarii tokko... </p>
  12. </div> jechuun ni danda’ama
  13. <div class = "moodaalii-jalqabaa" >
  14. <button class = "btn" data-dismiss = "moodaalii" aria-dhoksaa = "dhugaa" > Cufi </button>
  15. <button class = "btn btn-primary" > Jijjiiramoota saagi </button>
  16. </div> jechuun ni danda’ama
  17. </div> jechuun ni danda’ama

Fayyadama

Karaa amaloota deetaa

JaavaScript osoo hin barreessiin moodaalii tokko hojii irra oolchi. Qaama too'ataa irratti saagi data-toggle="modal", akka qaree, waliin data-target="#foo"ykn href="#foo"moodaalii murtaa'e jijjiiruuf irratti xiyyeeffachuuf.

  1. <button type = "button" data-toggle = "moodaalii" deetaa-galma = "#myModal" > Moodaalii </button> jalqabi

Karaa JaavaScript

Moodaalii id myModalqabu sarara JaavaScript tokkoon waami:

  1. $ ( '#Moodaalii koo' ). moodaalii ( filannoowwan ) .

Filannoowwan

Filannoon karaa amaloota deetaa ykn JaavaScript darbuu danda'u. Amaloota deetaatiif, maqaa filannoo gara data-, akkuma keessatti dabali data-backdrop="".

Maqaa akaakuu durtii ibsa
duubbee boolee dhugaa Qaama moodaalii-duubbee of keessaa qaba. staticAkka filannootti, duubbee kan moodaalii cuqaasuu irratti hin cufneef ifteessi .
kiiboordii boolee dhugaa Yeroo furtuun miliquu dhiibamu moodaalii cufa
agarsiisuu boolee dhugaa Moodaalii yeroo jalqabamu agarsiisa.
fagoo karaa soba

Yoo url fagoo kenname, qabiyyeen karaa loadmala jQuery'n fe'amee gara .modal-body. Yoo api deetaa fayyadamaa jirta ta'e, filannoodhaan hrefmadda fagoo ifteessuuf mallattoo fayyadamuu dandeessa. Fakkeenyi kanaa akka armaan gadiitti agarsiifameera:

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

Malawwan

.modal(filannoowwan) .

Qabiyyee kee akka moodaaliitti hojii irra oolcha. Filannoo filannoo tokko fudhata object.

  1. $ ( '#Moodaalii koo' ). moodaalii ({
  2. keyboard : soba
  3. }) .

.modal('jijjiirraa') .

Harkaan moodaalii tokko jijjiira.

  1. $ ( '#Moodaalii koo' ). modal ( 'jijjiirraa' ) .

.modal('agarsiisi') .

Harkaan moodaalii tokko bana.

  1. $ ( '#Moodaalii koo' ). modal ( 'agarsiisi' ) .

.modal('dhoksuu') .

Harkaan moodaalii tokko dhoksa.

  1. $ ( '#Moodaalii koo' ). modal ( 'dhoksuu' ) .

Taateewwan

Gitni moodaalii Bootstrap taateewwan muraasa gara dalagaa moodaaliitti hooking gochuuf saaxila.

Taatee Ibsa
agarsiisuu Taatee kun yeroo showmala fakkeenyaa waamamu battalumatti dhukaasa.
agarsiifameera Taatee kun kan dhukaafamu yeroo moodaaliin fayyadamaaf akka mul'atu godhame (ce'umsa css xumuramuu eega).
dhoksuu Taatee kun yeroo hidemala fakkeenyaa waamame battalumatti dhukaafama.
dhokataa Taatee kun kan dhukaafamu yeroo moodaaliin fayyadamaa irraa dhokfamuu xumuredha (ce'umsa css xumuramuu eega).
  1. $ ( '#Moodaalii koo' ). on ( 'dhokataa' , faankishinii () { .
  2. // waan tokko hojjedhu...
  3. }) .

Fakkeenya navbar keessatti

Ijaarsi ScrollSpy bakka tarree irratti hundaa'uun galmoota nav ofumaan fooyyessuuf. Naannoo navbar jala jiru garagalchiiti jijjiirama gita socho'aa ilaali. Wantoonni xiqqaan gadi bu'an akkasumas ni calaqqisu.

@furdaa

Beeksisa leggings keytar, brunch id dhaaba aartii dolor labore. Pitchfork yr enim lo-fi osoo isaan hin gurguratin qui. Tumblr qonnaa irraa gara minjaalaatti mirga biskileetii waanuma fedhe. Anim keffiyeh kaarlees kaardii. Velit seitan mcsweeney's suuraa booth 3 lukkuu ji'a irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui tarii waa'ee isaanii hin dhageenye et cardigan fandii imaanaa culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony baayoodiizeelii keffiyeh artiisan ullamco bu'aa.

@mdo jedhaa

Veniam marfa mustache iskeetiiboordii, adipisicing fugiat velit qeensa pitchfork. Freegan qeensa aliqua cupidat mcsweeney's vero jedhamuun beekama. Kuupidaat afur loko nisi, ea helvetica nulla carles. Tattooed cosby sweater konkolaataa nyaataa fe'umsaa, mcsweeney's quis non freegan vinyl. Lo-fi wes anderson +1 sartorial jedhamuun beekama. Carles sochii qaamaa miidhaginaa hin taane quis gentrify. Biruukiliin adipisicing hojii harkaa biiraa itti aanaa keytar deserunt.

tokko

Occaecat commodo aliqua delectus jedhamuun beekama. Fap hojii harkaa biiraa deserunt skateboard ea. Lomo mirga biskileetii adipisicing banh mi, velit ea sunt sadarkaa itti aanu locavore buna ka'umsa tokkoo magna veniam keessatti. Jireenya ol'aanaa id vaayinaayilii, echo paarkii consequat quis aliquip banh mi pitchfork. Vero VHS est adipisicing jedhamuun beekama. Consectetur nisi DIY boorsaa ergamaa xiqqaa. Cred ex in, itti fufiinsa kan qabu delectus consectetur fanny pack iphone.

lama

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 ergamaa boorsaa marfa waanuma fedhe delectus nyaata fe'umsaa. Sapiente synth id akka tilmaamaatti. Locavore sed helvetica cliche irony, thundercats tarii waa'ee isaanii hin dhageenye consequat hoodie gluten-free lo-fi fap aliquip. Labore elit placeat osoo isaan hin gurguramin dura, terry richardson proident brunch nesciunt quis cosby iswiiterii pariatur keffiyeh ut helvetica artisan. Cardigan biiraa hojii harkaa seitan qophaa'aa velit. VHS chambray laboris yeroodhaaf veniam. Anim mollit minim commodo ullamco qilleensaa.


Fayyadama

Karaa amaloota deetaa

Amala scrollspy salphaatti gara navigeeshinii barruu gubbaa keetti dabaluuf, data-spy="scroll"elementii irratti basaasuu barbaaddutti dabaluu qofa (baay'inaan kun qaama ta'a) fi data-target=".navbar"nav kam akka fayyadamtu filachuuf. Qaama waliin scrollspy fayyadamuu barbaadda .nav.

  1. <qaama deetaa-basaasaa = " tarree" deetaa-galma = ".navbar" > ... </body>

Karaa JaavaScript

Karaa JaavaScript gara scrollspy bilbili:

  1. $ ( '#navbar' ). barruulee () .
Mataa ol qaba! Hidhamtoonni Navbar galmoota id furmaata argachuu danda'an qabaachuu qabu. Fakkeenyaaf, a <a href="#home">home</a>waan dom keessa jiru akka <div id="home"></div>.

Malawwan

.scrollspy('haaraa') .

Yeroo scrollspy fayyadamtu elementoota DOM irraa dabaluu ykn haquu wajjin walqabatee, mala haaromsaa akkasitti waamuun si barbaachisa:

  1. $ ( '[daataa-basaasaa="tarree"]' ). tokkoon tokkoon ( faankishinii () { .
  2. var $ basaasaa = $ ( kana ). scrollspy ( 'haaromsaa' ) .
  3. });

Filannoowwan

Filannoon karaa amaloota deetaa ykn JaavaScript darbuu danda'u. Amaloota deetaatiif, maqaa filannoo gara data-, akkuma keessatti dabali data-offset="".

Maqaa akaakuu durtii ibsa
ofseeti jechuun ni danda’ama lakkoofsa 10. Piikseelota yeroo iddoo tarree shallagdu gubbaa irraa ofseeti.

Taateewwan

Taatee Ibsa
activate gochuu Taatee kun yeroo wanti haaraan scrollspy'n hojiirra oolu hundatti dhukaasa.

Fakkeenya caancalaa

Dalagaa caancala saffisaa, daayinamikii gara foddaa qabiyyee naannootti ce'uuf dabali, karaa qaaqa tarree illee.

Raw denim tarii waa'ee isaanii hin dhageenye jean shorts Austin. Nesciunt tofu stumptown aliqua, qulqullina gooftaa retro synth. Mustache cliche yeroodhaaf, williamsburg carles vegan helvetica jedhamuun beekama. Reprehenderit foon qalaa retro keffiyeh abjuu qabatu synth. Koosbii iswiiterii eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum afaan oromoo afaan oromoo. Seitan aliquip quis cardigan uffata ameerikaa, foon qalaa 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.


Fayyadama

Caancalawwan caancala qaban karaa JaavaScript dandeessisi (tokkoon tokkoon caancalaa dhuunfaan hojii irra oolchuu qaba):

  1. $ ( '#Tab koo a' ). cuqaasaa ( faankishinii ( e ) { .
  2. e . ittisuuDurtii ();
  3. $ ( kana ). tab ( 'agarsiisi' );
  4. }) .

Caancaloota dhuunfaa karaa hedduudhaan hojii irra oolchuu dandeessa:

  1. $ ( '#Tab koo a[href="#profaayilii"]' ). tab ( 'agarsiisi' ); // Caancala maqaadhaan filadhu
  2. $ ( '#Tab koo a:jalqaba' ). tab ( 'agarsiisi' ); // Caancala jalqabaa filadhu
  3. $ ( '#Tab koo a:dhuma' ). tab ( 'agarsiisi' ); // Caancala dhumaa filadhu
  4. $ ( '#Tab koo li:eq(2) a' ). tab ( 'agarsiisi' ); // Caancala sadaffaa filadhu (0-indexed) .

Markup gochuu

data-toggle="tab"JaavaScript kamiyyuu osoo hin barreessiin salphaatti ifteessuudhaan ykn data-toggle="pill"elementii tokko irratti navigeeshinii caancala ykn kiniinii hojii irra oolchuu dandeessa . Gitoota navfi gara caancalaatti dabaluudhaan akkaataa caancala Bootstrap hojii irra oolcha.nav-tabsul

  1. <ul gita = "nav nav-tabs" >
  2. <li><a href = "#mana" deetaa-jijjiirraa = "caancala" > Mana </a></li>
  3. <li><a href = "#profaayilii" deetaa-jijjiirraa = "caancala" > Profaayilii </a></li>
  4. <li><a href = "#ergaawwan" data-toggle = "caancala" > Ergaawwan </a></li>
  5. <li><a href = "#sajoo" data-toggle = "caancala" > Sajoo </a></li>
  6. </ul> jechuun ni danda’ama

Malawwan

$().caancala

Qabduu caancalaa fi qabduu qabiyyee hojii irra oolcha. Caancalli DOM keessatti noodiin qabduu a data-targetykn kan xiyyeeffatu qabaachuu qaba.href

  1. <ul class = "nav nav-tabs" id = "Tab koo" >
  2. <li class = "socho'aa" ><a href = "#mana" > Mana </a></li>
  3. <li><a href = "#profaayilii" > Profaayilii </a></li>
  4. <li><a href = "#ergaawwan" > Ergaawwan </a></li>
  5. <li><a href = "#sajoo" > Sajoo </a></li>
  6. </ul> jechuun ni danda’ama
  7.  
  8. <div class = "qabiyyee-caancala" >
  9. <div class = "caancala-qaree socho'aa" id = "mana" > ... </div>
  10. <div class = "caancala-qaaqa" id = "profaayilii" > ... </div>
  11. <div class = "caancala-qaaqa" id = "ergaawwan" > ... </div>
  12. <div class = "caancala-qaaqa" id = "qindaa'inoota" > ... </div>
  13. </div> jechuun ni danda’ama
  14.  
  15. <iskiriiptii>
  16. $ ( faankishinii () { .
  17. $ ( '#Tab koo a:dhuma' ). tab ( 'agarsiisi' );
  18. }) .
  19. </script> jedhu

Taateewwan

Taatee Ibsa
agarsiisuu Taatee kun agarsiisa caancalaa irratti dhukaasa, garuu osoo caancala haaraan hin agarsiifamiin dura. Caancala socho'aa fi caancala socho'aa duraanii (yoo jiraate) akkaataa wal duraa duubaan irratti xiyyeeffachuuf event.targetfi fayyadami .event.relatedTarget
agarsiifameera Taatee kun agarsiisa caancala irratti erga caancala agarsiifamee booda dhukaasa. Caancala socho'aa fi caancala socho'aa duraanii (yoo jiraate) akkaataa wal duraa duubaan irratti xiyyeeffachuuf event.targetfi fayyadami .event.relatedTarget
  1. $ ( 'a[deetaa-jijjiirraa="caancala"]' ). on ( 'agarsiifame' , faankishinii ( e ) { .
  2. e . target // caancala hojiirra oole
  3. e.relatedTarget // previous tab
  4. })

Examples

Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; Tooltips are an updated version, which don't rely on images, use CSS3 for animations, and data-attributes for local title storage.

Hover over the links below to see tooltips:

Tight pants next level keffiyeh you probably haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel have a terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan whatever keytar, scenester farm-to-table banksy Austin twitter handle freegan cred raw denim single-origin coffee viral.

Four directions


Usage

Trigger the tooltip via JavaScript:

  1. $('#example').tooltip(options)

Options

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-animation="".

Name type default description
animation boolean true apply a css fade transition to the tooltip
html boolean false Insert html into the tooltip. If false, jquery's text method will be used to insert content into the dom. Use text if you're worried about XSS attacks.
placement string|function 'top' how to position the tooltip - top | bottom | left | right
selector string false If a selector is provided, tooltip objects will be delegated to the specified targets.
title string | function '' default title value if `title` tag isn't present
trigger string 'hover' how tooltip is triggered - click | hover | focus | manual
delay number | object 0

delay showing and hiding the tooltip (ms) - does not apply to manual trigger type

If a number is supplied, delay is applied to both hide/show

Object structure is: delay: { show: 500, hide: 100 }

Heads up! Options for individual tooltips can alternatively be specified through the use of data attributes.

Markup

For performance reasons, the Tooltip and Popover data-apis are opt in. If you would like to use them just specify a selector option.

  1. <a href="#" rel="tooltip" title="first tooltip">hover over me</a>

Methods

$().tooltip(options)

Attaches a tooltip handler to an element collection.

.tooltip('show')

Reveals an element's tooltip.

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

.tooltip('hide')

Hides an element's tooltip.

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

.tooltip('toggle')

Toggles an element's tooltip.

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

.tooltip('destroy')

Hides and destroys an element's tooltip.

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

Examples

Add small overlays of content, like those on the iPad, to any element for housing secondary information. Hover over the button to trigger the popover. Requires Tooltip to be included.

Static popover

Four options are available: top, right, bottom, and left aligned.

Popover top

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

Popover right

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

Popover bottom

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

Popover left

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

No markup shown as popovers are generated from JavaScript and content within a data attribute.

Live demo

Four directions


Usage

Enable popovers via JavaScript:

  1. $('#example').popover(options)

Options

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-animation="".

Name type default description
animation boolean true apply a css fade transition to the tooltip
html boolean false Insert html into the popover. If false, jquery's text method will be used to insert content into the dom. Use text if you're worried about XSS attacks.
placement string|function 'right' how to position the popover - top | bottom | left | right
selector string false if a selector is provided, tooltip objects will be delegated to the specified targets
trigger string 'click' how popover is triggered - click | hover | focus | manual
title string | function '' default title value if `title` attribute isn't present
content string | function '' default content value if `data-content` attribute isn't present
delay number | object 0

delay showing and hiding the popover (ms) - does not apply to manual trigger type

If a number is supplied, delay is applied to both hide/show

Object structure is: delay: { show: 500, hide: 100 }

Heads up! Options for individual popovers can alternatively be specified through the use of data attributes.

Markup

For performance reasons, the Tooltip and Popover data-apis are opt in. If you would like to use them just specify a selector option.

Methods

$().popover(options)

Initializes popovers for an element collection.

.popover('show')

Reveals an elements popover.

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

.popover('hide')

Hides an elements popover.

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

.popover('toggle')

Toggles an elements popover.

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

.popover('destroy')

Hides and destroys an element's popover.

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

Example alerts

Add dismiss functionality to all alert messages with this plugin.

Holy guacamole! Best check yo self, you're not looking too good.

Oh snap! You got an error!

Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.

Take this action Or do this


Usage

Enable dismissal of an alert via JavaScript:

  1. $(".alert").alert()

Markup

Just add data-dismiss="alert" to your close button to automatically give an alert close functionality.

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

Methods

$().alert()

Wraps all alerts with close functionality. To have your alerts animate out when closed, make sure they have the .fade and .in class already applied to them.

.alert('close')

Closes an alert.

  1. $(".alert").alert('close')

Events

Bootstrap's alert class exposes a few events for hooking into alert functionality.

Event Description
close This event fires immediately when the close instance method is called.
closed This event is fired when the alert has been closed (will wait for css transitions to complete).
  1. $('#my-alert').bind('closed', function () {
  2. // do something…
  3. })

Example uses

Do more with buttons. Control button states or create groups of buttons for more components like toolbars.

Stateful

Add data-loading-text="Loading..." to use a loading state on a button.

  1. <button type="button" class="btn btn-primary" data-loading-text="Loading...">Loading state</button>

Single toggle

Add data-toggle="button" to activate toggling on a single button.

  1. <button type="button" class="btn btn-primary" data-toggle="button">Single Toggle</button>

Checkbox

Add data-toggle="buttons-checkbox" for checkbox style toggling on btn-group.

  1. <div class="btn-group" data-toggle="buttons-checkbox">
  2. <button type="button" class="btn btn-primary">Left</button>
  3. <button type="button" class="btn btn-primary">Middle</button>
  4. <button type="button" class="btn btn-primary">Right</button>
  5. </div>

Radio

Add data-toggle="buttons-radio" for radio style toggling on btn-group.

  1. <div class="btn-group" data-toggle="buttons-radio">
  2. <button type="button" class="btn btn-primary">Left</button>
  3. <button type="button" class="btn btn-primary">Middle</button>
  4. <button type="button" class="btn btn-primary">Right</button>
  5. </div>

Usage

Enable buttons via JavaScript:

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

Markup

Data attributes are integral to the button plugin. Check out the example code below for the various markup types.

Options

None

Methods

$().button('toggle')

Toggles push state. Gives the button the appearance that it has been activated.

Heads up! You can enable auto toggling of a button by using the data-toggle attribute.
  1. <button type="button" class="btn" data-toggle="button" ></button>

$().button('loading')

Sets button state to loading - disables button and swaps text to loading text. Loading text should be defined on the button element using the data attribute data-loading-text.

  1. <button type="button" class="btn" data-loading-text="loading stuff..." >...</button>
Heads up! Firefox persists the disabled state across page loads. A workaround for this is to use autocomplete="off".

$().button('reset')

Resets button state - swaps text to original text.

$().button(string)

Resets button state - swaps text to any data defined text state.

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

About

Get base styles and flexible support for collapsible components like accordions and navigation.

* Requires the Transitions plugin to be included.

Example accordion

Using the collapse plugin, we built a simple accordion style widget:

Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
  1. <div class="accordion" id="accordion2">
  2. <div class="accordion-group">
  3. <div class="accordion-heading">
  4. <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
  5. Collapsible Group Item #1
  6. </a>
  7. </div>
  8. <div id="collapseOne" class="accordion-body collapse in">
  9. <div class="accordion-inner">
  10. Anim pariatur cliche...
  11. </div>
  12. </div>
  13. </div>
  14. <div class="accordion-group">
  15. <div class="accordion-heading">
  16. <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
  17. Collapsible Group Item #2
  18. </a>
  19. </div>
  20. <div id="collapseTwo" class="accordion-body collapse">
  21. <div class="accordion-inner">
  22. Anim pariatur cliche...
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. ...

You can also use the plugin without the accordion markup. Make a button toggle the expanding and collapsing of another element.

  1. <button type="button" class="btn btn-danger" data-toggle="collapse" data-target="#demo">
  2. simple collapsible
  3. </button>
  4.  
  5. <div id="demo" class="collapse in"></div>

Usage

Via data attributes

Just add data-toggle="collapse" and a data-target to element to automatically assign control of a collapsible element. The data-target attribute accepts a css selector to apply the collapse to. Be sure to add the class collapse to the collapsible element. If you'd like it to default open, add the additional class in.

To add accordion-like group management to a collapsible control, add the data attribute data-parent="#selector". Refer to the demo to see this in action.

Via JavaScript

Enable manually with:

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

Options

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-parent="".

Name type default description
parent selector false If selector then all collapsible elements under the specified parent will be closed when this collapsible item is shown. (similar to traditional accordion behavior)
toggle boolean true Toggles the collapsible element on invocation

Methods

.collapse(options)

Activates your content as a collapsible element. Accepts an optional options object.

  1. $('#myCollapsible').collapse({
  2. toggle: false
  3. })

.collapse('toggle')

Toggles a collapsible element to shown or hidden.

.collapse('show')

Shows a collapsible element.

.collapse('hide')

Hides a collapsible element.

Events

Bootstrap's collapse class exposes a few events for hooking into collapse functionality.

Event Description
show This event fires immediately when the show instance method is called.
shown This event is fired when a collapse element has been made visible to the user (will wait for css transitions to complete).
hide This event is fired immediately when the hide method has been called.
hidden This event is fired when a collapse element has been hidden from the user (will wait for css transitions to complete).
  1. $('#myCollapsible').on('hidden', function () {
  2. // do something…
  3. })

Example

A basic, easily extended plugin for quickly creating elegant typeaheads with any form text input.

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

Usage

Via data attributes

Add data attributes to register an element with typeahead functionality as shown in the example above.

Via JavaScript

Call the typeahead manually with:

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

Options

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-source="".

Name type default description
source array, function [ ] The data source to query against. May be an array of strings or a function. The function is passed two arguments, the query value in the input field and the process callback. The function may be used synchronously by returning the data source directly or asynchronously via the process callback's single argument.
items number 8 The max number of items to display in the dropdown.
minLength number 1 The minimum character length needed before triggering autocomplete suggestions
matcher function case insensitive The method used to determine if a query matches an item. Accepts a single argument, the item against which to test the query. Access the current query with this.query. Return a boolean true if query is a match.
sorter function exact match,
case sensitive,
case insensitive
Method used to sort autocomplete results. Accepts a single argument items and has the scope of the typeahead instance. Reference the current query with this.query.
updater function returns selected item The method used to return selected item. Accepts a single argument, the item and has the scope of the typeahead instance.
highlighter function highlights all default matches Method used to highlight autocomplete results. Accepts a single argument item and has the scope of the typeahead instance. Should return html.

Methods

.typeahead(options)

Initializes an input with a typeahead.

Example

The subnavigation on the left is a live demo of the affix plugin.


Usage

Via data attributes

To easily add affix behavior to any element, just add data-spy="affix" to the element you want to spy on. Then use offsets to define when to toggle the pinning of an element on and off.

  1. <div data-spy="affix" data-offset-top="200">...</div>
Heads up! You must manage the position of a pinned element and the behavior of its immediate parent. Position is controlled by affix, affix-top, and affix-bottom. Remember to check for a potentially collapsed parent when the affix kicks in as it's removing content from the normal flow of the page.

Via JavaScript

Call the affix plugin via JavaScript:

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

Methods

.affix('refresh')

When using affix in conjunction with adding or removing of elements from the DOM, you'll want to call the refresh method:

  1. $('[data-spy="affix"]').each(function () {
  2. $(this).affix('refresh')
  3. });

Options

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-offset-top="200".

Name type default description
offset number | function | object 10 Piikseelota yeroo iddoo tarree shallagdu iskiriinii irraa ofseeti. Yoo lakkoofsi tokko kenname, ofseeti kallattii gubbaa fi bitaa lamaan isaaniitiin hojiirra oola. Kallattii tokkoof, ykn ofseetota addaa hedduu dhaggeeffachuuf, wanta tokko qofa kenni offset: { x: 10 }. Yeroo ofseeti daayinamiikiin kennuu barbaaddu faankishinii fayyadami (dizaayinoota deebii kennanii tokko tokkoof faayidaa qaba).