Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery draggable with bootstrap modal, scroller strange behaviour

I'm trying to use bootstrap modal popup with jquery-ui draggable functionality. I use it like this:

        // Bootstrap modal
        $(element).modal({ keyboard: false,
                           show: value
        });
        // Jquery draggable
        $(element).draggable({
            handle: ".modal-header"
        });

But when I try to drag the popup right scroller is dragging with popup. Thx for any advance.

like image 905
Maris Avatar asked Nov 25 '14 07:11

Maris


1 Answers

i think you should apply draggable on the .modal-dialog class, see:

  
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>

<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<div>
<div class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title">Modal title</h4>
      </div>
      <div class="modal-body">
        <p>One fine body&hellip;</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal --> 
</div>

<script>
        $('.modal').modal({ keyboard: false,
                           show: true
        });
        // Jquery draggable
        $('.modal-dialog').draggable({
            handle: ".modal-header"
        });
</script>  
like image 188
Bass Jobsen Avatar answered Oct 25 '22 08:10

Bass Jobsen