This page illustrates how to integrate javascript with the Bootstrap library. Below we go over the basics and provide you with some awesome plugins to get you started!

What is all this?

With this example page, we've set out to make your interactive work with Bootstrap even more simple, offering several lightweight plugins for things like modals, tooltips, and other dynamic components. These plugins have been coded up to work with jQuery and Ender, but we encourage you to extend and modify them to fit your development needs!

Do I need these?

The short answer is NO! These plugins were provided to help you understand how to integrate bootstrap with javascript and to give you a quick lightweight option for dropping something in and getting the basic functionality.

Our Modal plugin is super slim! We took special care to only include the bare functionality that we require at twitter, however we look forward to seeing all the cool stuff you do with it!

Using bootstrap-modal

$('#modal-content').modal();

Options

  • backdrop (boolean) - if true, it will include a modal-backdrop element.
  • closeOnEscape (boolean) - if true, it will close the modal when escape key is pressed.
  • content (string) - alternative way of supplying modal class with HTML content.

Methods

$.modal

Returns an instance of the modal class. It accepts either a string or an options object.

// Accepts HTML string
$.modal(modalHTML)

// Accepts Options
$.modal({
  backdrop: true
, content: modalHTML
})

$().modal

Returns an instance of the modal class. Accepts an optional options object.

$('#modal-content').modal({
  closeOnEscape: true
});

.toggle

Returns an instance of the modal class. Toggle the modal open state.

$('#modal-content').modal().toggle()

.open

Returns an instance of the modal class. Opens the modal.

$('#modal-content').modal().open()

.close

Returns an instance of the modal class. Closes the modal.

$('#modal-content').modal().close()

Demo