I'm using jQuery UI to allow elements of a class. However i'd like the rest of the elements of a class to follow when one of them is being dragged. How can I do that?
So when one is dragged the rest of the class are also being dragged.
I attempted to trigger mousedown on start and mouseup on stop events on the elements so that the dragging would happen for the others when one of them is being dragged?
$('.dismissAllButton').draggable({ axis:'x', containment:'parent', start:function(){ upEvent = false; $(this).mousedown(); }, drag: function(){ $(this).mousemove(); }, stop:function(){ $(this).mouseup(); setTimeout(function(){ upEvent = true; }, 1000); }});
I also tried making itself the parent so that the others would also be dragged / follow when one of them was being dragged, but that didn't work.
$('.dismissAllButton').draggable({ axis:'x', containment:'parent', handle:'.dismissAllButton', start:function(){ upEvent = false; }, stop:function(){ setTimeout(function(){ upEvent = true; }, 1000); }});
Fiddles:
No following, just one element dragging: http://jsfiddle.net/7ta68xyt/
attempt 1, code sample 1 above, : http://jsfiddle.net/7ta68xyt/1/
attempt 2, code sample 2 above, : http://jsfiddle.net/7ta68xyt/2/
Update: I found a script on github that allows for this, but the other elements all lag behind a bit. How can I get them to lag at intervals and the end up at the same place when dragging stops or have them all drag the same ( no lag ).
Here is the fiddle: http://jsfiddle.net/7ta68xyt/3/
Here is the script: https://github.com/javadoug/jquery.drag-multiple