I have a div element 'slide' in the parent container of the div 'box' and applied JQuery Draggable to the child. While the item is being dragged, I resize the parent container, sometimes shrinking, sometimes increasing it.
The problem is that jQuery does not respond to this resizing and still contains the draggable element in the original dimensions of the parent, and not within its current size, to the mouse - the next drag and drop session will use the new dimensions (until it changes again).
To try to solve this problem, I was hoping to trigger a mouseup event, followed by a mousedown event, so that jQuery would use the new container size:
$('.slide').draggable({ axis: "x", containment: 'parent', drag: function (e, ui) { resizeContainer(); if (outsideContainer()){ // Try to stop and restart dragging $(this).trigger('mouseup'); $(this).trigger('mousedown'); } }
However, this throws an exception ...
Unable to get value of the property '0': object is null or undefined
... in this line of jQuery code:
this.helper[0].style.left=this.position.left+"px";
Does anyone know how I can: a) get Draggable to respond in real time to changes in the parent dimensions or b) trigger a drag and then drag smoothly?
Thank.
jquery triggers draggable
Fijjit May 04 '12 at 21:15 2012-05-04 21:15
source share