Drag from select

11 views
Skip to first unread message

Ury Danko

unread,
Nov 28, 2009, 11:45:02 AM11/28/09
to threedubmedia
Hi

Is there the way to start dragging from the <select> ? Code example
below doesn't work :(

<select multiple>
<option id="unit">pawn</option>
</select>
...
$(function(){
$("#unit").bind("dragstart", function(event) {
console.log("Unit Drag Start");
});
});

3wme

unread,
Dec 1, 2009, 12:14:35 PM12/1/09
to threedubmedia
It does not seem to work very well in all browsers. Firefox seems OK
for a start.

The first need is to tell the drag script to allow dragging in form
elements, which is prohibited by default:

$.event.special.drag.not = "";

The second trick is to do a little event delegation and actually bind
the events to the select elements instead of the options.

The third trick is to use a proxy element, because orphaned options
elements don't really behave nicely.

http://jsbin.com/uvewa

Again, this does not work well in Chrome or MSIE, so ultimately I
would recommend replacing the select elements with some other
controllable markup.

Ury Danko

unread,
Dec 1, 2009, 2:09:15 PM12/1/09
to threedubmedia

yes... while I was waiting for response I got the same idea - replace
<select> by <div>'s
but thank you for answer :)
Reply all
Reply to author
Forward
0 new messages