I am currently looking for a software/web development job preferably as a Rails-based developer.
Please email me at weston@westonganger.com. Thanks in advance for any leads!

How To Completely Remove Bootstrap Modal In Bootstrap 2 And 3

Posted by Weston Ganger

Having closed modal’s hang around in the background can be very annoying and cause unexpected selector behaviour. Here are methods to completely remove the modal when its hidden.

Bootstrap 3

/* Automatically */
$(".modal").on('hidden.bs.modal', function () {
  $(this).data('bs.modal', null);

/* Manually */
$( '.modal' ).modal( 'hide' ).data( 'bs.modal', null );

Bootstrap 2

/* Automatically */
$('body').on('hide', '.modal', function(e){
  $(e.target).data('modal', null);

/* Manually */
$('body').removeClass( "modal-open" );

Related External Links:

Article Topic:Software Development - Javascript

Date:January 05, 2017

Recommended Posts