Ticket #1993 (closed bug: fixed)
trigger doesn't return value when function is passed with extra parameter
| Reported by: | pwoldberg | Owned by: | davidserduke |
|---|---|---|---|
| Priority: | critical | Milestone: | 1.2.2 |
| Component: | event | Version: | 1.2.1 |
| Keywords: | event trigger | Cc: | |
| Blocking: | Blocked by: |
Description
In ui.draggable.js the following code is used:
var nv = $(this.element).triggerHandler("drag", [e, that.prepareCallbackObj(this)], o.drag);
a value to nv is only returned when using .bind('drag', function) on the draggable element, if you use the drag from the options it will not return the value.
The problem is in the event component:
174 if ( extra && extra.apply( element, data ) === false ) 175 val = false;
it will only return false but no other values.
Change History
comment:1 Changed 6 years ago by davidserduke
- need changed from Review to Test Case
- Owner set to davidserduke
- Status changed from new to assigned
comment:2 Changed 6 years ago by pwoldberg
It gives back a value if bind is used. The problem is when bind is not used but the function is passed using the extra parameter of the trigger function.
The ui.draggable uses the triggerHandler function to trigger the event and passes the o.drag, which is the drag function set in the options. I want to use the return to restrict the position of the draggable element.
It could also be that it is used wrong in the draggable plugin.
comment:3 Changed 6 years ago by davidserduke
Ahh, ok I understand what you are saying now. I didn't think that was how the extra function was supposed to work (and it isn't programmed that way) but maybe it should be. And clearly ui.draggable is trying to. I'll do a bit more research and see what I can find out.
comment:4 Changed 6 years ago by davidserduke
- need changed from Test Case to Review
- Status changed from assigned to closed
- Resolution set to fixed
Fixed in [4001]. Although more of a design change than a bug fix, the extra function now will overwrite the return value unless undefined is returned either explicitly by the function or by the lack of any other return value.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

I'm not sure I follow the problem. If you look at the jQuery.trigger function (that you clipped that section above out of) you'll see it sets the val variable in several places including
so trigger could return other values in theory. But as event handlers usually return either nothing (undefined) or false, this typically isn't an issue.
What do you expect to be returned? I'm not familiar with the drag code so any other test case you have showing the problem would be useful.