O'Reilly logo

Extending Bootstrap by Christoffer Niska

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Extending Bootstrap plugins

Sometimes, you need to extend the functionality of the Bootstrap plugins, and when you do, it is important that you know how to do it correctly. There are many ways to extend plugins. We will cover a single approach that you can implement in your projects to extend any Bootstrap plugin.

As an example, let us take a look at how you can extend the Bootstrap Modal plugin.

Create a new JavaScript file named custom-modal.js and add the following contents:

(function ($) { // enable ES5 strict mode 'use strict'; // save the original plugin var _parent = $.fn.modal; // define your own constructor var Modal = function(element, options) { _parent.Constructor.apply(this, arguments); // console.log calls are here just to see that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required