Skip to content

Instantly share code, notes, and snippets.

@wellwind
Last active March 31, 2024 08:12
Show Gist options
  • Select an option

  • Save wellwind/a5a10222ad691d72a11c to your computer and use it in GitHub Desktop.

Select an option

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>
@nathanielstenzel

Copy link
Copy Markdown

Thanks so much for posting this! A project I got involved in lately had some weird bug where dragging the window would drag the parent window's scroll bar. This fixed it!

ghost commented Jan 16, 2016

Copy link
Copy Markdown

Thanks from me too! Saved github.com/openhardwarecoza/LaserWeb (: from the scrollbar dragging with the modal. @nathanielstenzel sent me the pull and I merged it this morning.

Laserweb is a node.js based, in browser CAM/Machine control for Laser Cutters

@cannandev

Copy link
Copy Markdown

Exactly what I was looking for. Thanks!

@SlyNet

SlyNet commented Oct 12, 2016

Copy link
Copy Markdown

Is it possible to make it non modal? Thanks.

@Jonas92

Jonas92 commented Nov 23, 2016

Copy link
Copy Markdown

Exactly what i needed! It was so helpful!!

Thanks!!

@constantinokv

Copy link
Copy Markdown

Thanks very much, it's just I need and helpful!. 💯

@dhanilkumart

Copy link
Copy Markdown

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

dudzz commented Apr 15, 2020

Copy link
Copy Markdown

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

@theoldman73

Copy link
Copy Markdown

i need full example for using it

@ianmora97

Copy link
Copy Markdown

Very helpful!! Thanks!

@yu5t1n4ng

Copy link
Copy Markdown

cannot work

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