I'm trying to make bootstrap twitter dialog modal draggable with this jquery plugin:
http://threedubmedia.com/code/event/drag#demos
but it doesn't work.
var $div = $('html');
console.debug($('.drag'));
$('#modalTest')
.drag("start", function(ev, dd) {
dd.limit = $div.offset();
dd.limit.bottom = dd.limit.top + $div.outerHeight() - $(this).outerHeight();
dd.limit.right = dd.limit.left + $div.outerWidth() - $(this).outerWidth();
})
.drag(function(ev, dd) {
$(this).css({
top: Math.min(dd.limit.bottom, Math.max(dd.limit.top, dd.offsetY))
, left: Math.min(dd.limit.right, Math.max(dd.limit.left, dd.offsetX))
});
});
Have you idea how can I do it?
it works for me. I got it from there. if you give me thanks please give 70% to Andres Ilich
The top-ranked solution (by Mizbah Ahsan) is not quite right ...but is close. If you apply draggable() to the modal dialog element, the browser window scroll bars will drag around the screen as you drag the modal dialog. The way to fix that is to apply draggable() to the modal-dialog class instead:
Thanks!
In my own case, i had to set
backdrop
and set thetop
andleft
properties before i could applydraggable
function on the modal dialog. Maybe it might help someone ;)Like others said, the simpliest solution is just call
draggable()
function from jQuery UI just after showing modal:But there is a several problems with compatibility between Bootstrap and jQuery UI so we need some addition fixes in css:
i did this:
and it make my very standard/basic modal draggable.
not sure how/why it worked, but it did.
In my case I am enabling draggable. It works.
Might be it helps you.