Skip to content

Instantly share code, notes, and snippets.

@wellwind
Last active March 31, 2024 08:12
Show Gist options
  • Save wellwind/a5a10222ad691d72a11c to your computer and use it in GitHub Desktop.
Save wellwind/a5a10222ad691d72a11c to your computer and use it in GitHub Desktop.
Draggable Bootstrap Modal
$('.modal.draggable>.modal-dialog').draggable({
cursor: 'move',
handle: '.modal-header'
});
$('.modal.draggable>.modal-dialog>.modal-content>.modal-header').css('cursor', 'move');
  1. requires jquery.js and jquery.ui.js
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.ui.js"></script>
  1. add class draggable to modal container.
<div class="modal draggable fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">...</div>
            <div class="modal-body">...</div>
            <div class="modal-footer">...</div>
        </div>
    </div>
</div>
@dhanilkumart
Copy link

The modal is scrolling above the window, once it moved under browser bar we have to refresh the page. How can i fix it?? prevent dragging out a parent

@dudzz
Copy link

dudzz commented Apr 15, 2020

Thank you so much. It works perfectly. It's what exactly what I've been looking for.

@theoldman73
Copy link

i need full example for using it

@ianmora97
Copy link

Very helpful!! Thanks!

@yu5t1n4ng
Copy link

cannot work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment