Opened 14 years ago
Closed 13 years ago
#3876 closed enhancement (wontfix)
create draggable on mousedown
Reported by: | ecentinela | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.8 |
Component: | ui.draggable | Version: | 1.6rc5 |
Keywords: | draggable mousedown | Cc: | |
Blocked by: | Blocking: |
Description
Before 1.6 this was posible with the code:
$('img').bind('mousedown', function(e) { $(this).draggable().trigger('mousedown.draggable', e); })
But with 1.6rc5, this doesn't works. I think that creating draggables by demand could be a great enhacement. I know this can be done with the new live method on jquery, but creating draggables on mousedown is a better solution to avoid overhead.
Change History (4)
comment:1 Changed 14 years ago by
comment:2 Changed 14 years ago by
Component: | ui.core → ui.draggable |
---|---|
Milestone: | TBD → 1.6 |
Probably a regression.
comment:3 Changed 14 years ago by
Milestone: | 1.7 → 1.8 |
---|
comment:4 Changed 13 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
It's a change that was needed in jQuery core, so jQuery core simply doesn't accept events being passed anymore as data. However, there's a new way of doing this, which is even simpler:
$('#draggable').one('mousedown', function(e) {
$("#draggable").draggable().trigger(e);
});
So you bind a onetime executed event to mousedown, and then simply retrigger the mousedown event using trigger(e) (that way you won't have an infinite recursion). This works like a charm!
After some research I have seen that I can do:
It's not too much friendly, but this works. Maybe some option on the draggable method could be introduced for this purpose.