Javascript para Bootstrap

Da vida aos compoñentes de Bootstrap con novos complementos personalizados que funcionan con jQuery e Ender .

← Volver ao inicio de Bootstrap

Este complemento serve para engadir a interacción scrollspy (nav de actualización automática) á barra superior de arranque.

Descargar

Usando bootstrap-scrollspy.js

  1. $ ( '#barra superior' ). scrollSpy ()

Marcado

Para engadir facilmente o comportamento scrollspy ao teu navegador, só tes que engadir o data-scrollspyatributo ao ficheiro .topbar.

  1. <div class = "topbar" data-scrollspy = "scrollspy" > ... </div>

Métodos

$().scrollSpy()

Auto activa os botóns de navegación pola posición de desprazamento dos usuarios.

  1. $ ( 'corpo > .topbar' ). scrollSpy ()

Teña en conta que as etiquetas de ancoraxe Topbar deben ter obxectivos de identificación resolubles. Por exemplo, un <a href="#home">home</a>debe corresponder a algo no dom como <div id="home"></div>.

.scrollSpy('actualizar')

O scrollspy almacena en caché os botóns de navegación e as coordenadas de sección para o rendemento. Se precisas actualizar esta caché (probablemente se tes contido dinámico), só tes que chamar a este método de actualización. Se usaches o atributo de datos para definir o teu scrollspy, só tes que chamar a refresh no corpo.

  1. $ ( 'corpo' ). scrollSpy ( 'actualizar' )

Demostración

Consulta a navegación da barra superior nesta páxina.

Este complemento ofrece unha funcionalidade adicional para xestionar o estado do botón.

Descargar

Usando bootstrap-buttons.js

  1. $ ( '.tabs' ). botón ()

Métodos

$().button('alternar')

Alterna o estado push. Dálle a btn o aspecto de que foi activado.

Aviso Pode activar a alternancia automática dun botón usando o data-toggleatributo.

  1. <button class = "btn" data-toggle = "alternar" > ... </button>

$().button('cargando')

Establece o estado do botón para cargar: desactiva o botón e cambia o texto polo texto de carga. O texto de carga debe definirse no elemento botón mediante o atributo data data-loading-text.

  1. <button class = "btn" data-loading-text = "cargando cousas..." > ... </button>

$().button('restablecer')

Restablece o estado do botón: cambia o texto polo texto orixinal.

$().button(cadea)

Restablece o estado do botón: cambia o texto por calquera estado de texto definido por datos.

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

Demostración

Este complemento engade funcións de pestanas e pílulas rápidas e dinámicas.

Descargar

Usando bootstrap-tabs.js

  1. $ ( '.tabs' ). fichas ()

Marcado

Podes activar unha navegación por pestanas ou pílulas sen escribir ningún javascript simplemente dándolles un data-tabsou un data-pillsatributo.

  1. <ul class = "tabs" data-tabs = "tabs" > ... </ul>

Métodos

$().tabs ou $().pílulas

Activa a funcionalidade de pestanas e pílulas para un determinado recipiente. As ligazóns das pestanas deben facer referencia aos identificadores do documento.

  1. <ul class = "pestanas" >
  2. <li class = "active" ><a href = "#home" > Inicio </a></li>
  3. <li><a href = "#profile" > Perfil </a></li>
  4. <li><a href = "#messages" > Mensaxes </a></li>
  5. <li><a href = "#settings" > Configuración </a></li>
  6. </ul>
  7.  
  8. <div class = "contido da pílula" >
  9. <div class = "active" id = "home" > ... </div>
  10. <div id = "perfil" > ... </div>
  11. <div id = "mensaxes" > ... </div>
  12. <div id = "configuración" > ... </div>
  13. </div>
  14.  
  15. <script>
  16. $ ( función () {
  17. $ ( '.tabs' ). fichas ()
  18. })
  19. </script>

Eventos

Evento Descrición
cambiar Este evento desenvólvese ao cambiar de pestana. Use event.targete event.relatedTargetpara apuntar á pestana activa e á pestana activa anterior respectivamente.
  1. $ ( '#.pestañas' ). ligar ( 'cambiar' , función ( e ) {
  2. e . destino // pestana activada
  3. e . relatedTarget // pestana anterior
  4. })

Demostración

Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.

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

Banksy do proident, brooklyn photo booth delectus sunt artisan sed organic exercitation eiusmod four loko. Quis tattooed iphone esse aliqua. Master cleanse vero fixie mcsweeney's. Ethical portland aute, irony food truck pitchfork lomo eu anim. Aesthetic blog DIY, ethical beard leggings tofu consequat whatever cardigan nostrud. Helvetica you probably haven't heard of them carles, marfa veniam occaecat lomo before they sold out in shoreditch scenester sustainable thundercats. Consectetur tofu craft beer, mollit brunch fap echo park pitchfork mustache dolor.

Sunt qui biodiesel mollit officia, fanny pack put a bird on it thundercats seitan squid ad wolf bicycle rights blog. Et aute readymade farm-to-table carles 8-bit, nesciunt nulla etsy adipisicing organic ea. Master cleanse mollit high life, next level Austin nesciunt american apparel twee mustache adipisicing reprehenderit hoodie portland irony. Aliqua tofu quinoa +1 commodo eiusmod. High life williamsburg cupidatat twee homo leggings. Four loko vinyl DIY consectetur nisi, marfa retro keffiyeh vegan. Fanny pack viral retro consectetur gentrify fap.

Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.

Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.

Based on the excellent jQuery.tipsy plugin written by Jason Frame; twipsy is an updated version, which doesn't rely on images, uses css3 for animations, and data-attributes for title storage!

Download

Using bootstrap-twipsy.js

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

Options

Name type default description
animate boolean true apply a css fade transition to the tooltip
delayIn number 0 delay before showing tooltip (ms)
delayOut number 0 delay before hiding tooltip (ms)
fallback string '' text to use when no tooltip title is present
placement string 'above' how to position the tooltip - above | below | left | right
html boolean false allows html content within tooltip
live boolean false use event delegation instead of individual event handlers
offset number 0 pixel offset of tooltip from target element
title string, function 'title' attribute or method for retrieving title text
trigger string 'hover' how tooltip is triggered - hover | focus | manual
template string [default markup] The html template used for rendering a twipsy.

Notice Individual twipsy instance options can alternatively be specified through the use of data attributes.

  1. <a href="#" data-placement="below" rel='twipsy' title='Some title text'>text</a>

Methods

$().twipsy(options)

Attaches a twipsy handler to an element collection.

.twipsy('show')

Reveals an elements twipsy.

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

.twipsy('hide')

Hides an elements twipsy.

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

.twipsy(true)

Returns an elements twipsy class instance.

  1. $('#element').twipsy(true)

Notice Alternatively, this can be retrieved with $().data('twipsy').

Demo

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.

The popover plugin provides a simple interface for adding popovers to your application. It extends the bootstrap-twipsy.js plugin, so be sure to grab that file as well when including popovers in your project!

Notice You must include the bootstrap-twipsy.js file before bootstrap-popover.js.

Download

Using bootstrap-popover.js

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

Options

Name type default description
animate boolean true apply a css fade transition to the tooltip
delayIn number 0 delay before showing tooltip (ms)
delayOut number 0 delay before hiding tooltip (ms)
fallback string '' text to use when no tooltip title is present
placement string 'right' how to position the tooltip - above | below | left | right
html boolean false allows html content within tooltip
live boolean false use event delegation instead of individual event handlers
offset number 0 pixel offset of tooltip from target element
title string, function 'title' attribute or method for retrieving title text
content string, function 'data-content' a string or method for retrieving content text. if none are provided, content will be sourced from a data-content attribute.
trigger string 'hover' how tooltip is triggered - hover | focus | manual
template string [default markup] The html template used for rendering a popover.

Notice Individual popover instance options can alternatively be specified through the use of data attributes.

  1. <a data-placement="below" href="#" class="btn danger" rel="popover">text</a>

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')

Demo

hover for popover

The alert plugin is a super tiny class for adding close functionality to alerts.

Download

Using bootstrap-alerts.js

  1. $(".alert-message").alert()

Markup

Just add a data-alert attribute to your alert messages to automatically give them close functionality.

Options

Name type default description
selector string '.close' What selector to target for closing an alert.

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-message").alert('close')

Demo

×

Santo guacamole! É mellor que te comprobes, non tes demasiado bo aspecto.

×

¡Oh! Tes un erro! Cambia isto ou outro e téntao de novo. Duis mollis, is not commodo luctus, ninsi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.