Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#7452 closed bug (notabug)

dragstart event is triggered for disabled draggables

Reported by: AD7six Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.draggable Version: 1.8.13
Keywords: Cc:
Blocked by: Blocking:

Description

As shown in this image:

http://ad7six.com/dump/jqueryui-draggable.png

the dragstart event of a disabled draggable is still triggered.

For completeness (and in the event the image is deleted in the future) this code:

$('#draggable')
    .draggable('disable')
    .bind('dragstart', function() { alert("You started dragging"); } );

Will display an alert if you attempt to drag #draggable.

I'm not sure if this is by design, but it was certainly unexpected. So, either a documentation fix, me-education, or a code change appears to be in order :)

Change History (8)

comment:1 Changed 9 years ago by Scott González

Resolution: worksforme
Status: newclosed

I'm not sure what steps you're using, but there are no events being triggered for disabled draggables for me. Please provide a reduced test case if you continue having problems.

comment:2 Changed 9 years ago by AD7six

Thank you for taking the time to really dig into the ticket :D - at least I can reopen it with these duplicate instructions.

I'm not sure how to create a test case for a mouse movement, so the steps to reproduce the problem are (I thought this was obvious, and I reproduced it right-now in Chrome 10 linux, Chrome 11 windows, Firefox 4.0 Window and IE 9 )

  • Go to http://jqueryui.com/demos/draggable/
  • Open the console and type $('#draggable').draggable('disable');
  • then type type $('#draggable').bind('dragstart', function() { alert("You started dragging"); } );
  • Drag the draggable (a few times in different places)

An alert will appear.

If it's not happening for you perhaps you could explain how I got that screenshot?

comment:3 Changed 9 years ago by Scott González

Sorry, when I said "I'm not sure what steps you're using" I meant I didn't know if you had run those lines in the console then changed which demo you were using.

I've gotten confirmation from another developer that this is working properly for him too.

comment:4 Changed 9 years ago by AD7six

Cool - Do either of you have a suggestion for

  • how I got that screenshot (I could generate another one in any browser right now)
  • how to write a suitable test case?

Alternatively, the output of dragging around on this http://jsbin.com/aboto4/7 is an alert and this debug output

jQuery.Event
altKey: false
attrChange: undefined
attrName: undefined
bubbles: true
button: 0
cancelable: true
charCode: 0
clientX: 64
clientY: 79
ctrlKey: false
currentTarget: HTMLDivElement
data: undefined
detail: 0
eventPhase: 2
fromElement: null
handleObj: Object
handler: function (e) { window.top.console.log(e); window.top.console.trace(); alert("yes, you did it"); }
isDefaultPrevented: function returnFalse() {
jQuery16107274469290859997: true
keyCode: 0
layerX: 56
layerY: 71
metaKey: false
newValue: undefined
offsetX: 56
offsetY: 71
originalEvent: MouseEvent
pageX: 64
pageY: 79
prevValue: undefined
relatedNode: undefined
relatedTarget: null
screenX: 64
screenY: 202
shiftKey: false
srcElement: HTMLDivElement
target: HTMLDivElement
timeStamp: 1307394067445
toElement: HTMLDivElement
type: "dragstart"
view: DOMWindow
wheelDelta: undefined
which: 1
__proto__: Object
console.trace()
(anonymous function)4:46
jQuery.event.handlejquery.js:2926
jQuery.event.add.elemData.handle.eventHandlejquery.js:2560

I can appreciate you're having difficulties reproducing but an almost immediate wfm seems pretty inappropriate given what appears to be a blatant problem - unless you think I would photoshop an alert onto a screenshot.

comment:5 Changed 9 years ago by AD7six

Maybe this helps convince you to press that reopen-ticket button (go on, you know you want to):

This appears to be 100% reproducible:

  • Select some text in a draggable (e.g. double click on a word in the draggable)
  • Then drag the draggable.
  • Alert every time for me.

comment:6 Changed 9 years ago by Scott González

Resolution: worksforme
Status: closedreopened

Ok, so the text selection was the key. This isn't the draggable plugin though, that's a native dragstart event. That's unfortunate.

comment:7 Changed 9 years ago by Scott González

Resolution: invalid
Status: reopenedclosed

comment:8 Changed 9 years ago by AD7six

would you mind explaining how unexpected behavior is invalid and how users can avoid this - or point at where in the documentation it tells users that this particular case is "correct"

Note: See TracTickets for help on using tickets.