How do I prevent dragging when a button is clicked within the draggable container?
I have this:
- <script>
- $(function() {
- $('.draggable').draggable();
- $('.clickable').click(function(e) {
- alert('hi!');
- });
- })
- </script>
- <div class="draggable">
- <a href="#" class="clickable">click</a>
- </div>
Right now if I click & hold on the 'click' link, then drag mouse, the draggable container is dragged. Then when I release the mouse button, the click() happens.
This is what I want: if a user drags anywhere on the draggable, it drags. *Except*, if the user clicks on a clickable, then it does not drag.
Is there a way to 'cancel' the drag even from the clickable element so that it doesn't propagate to the draggable container?
Thanks!