Skip to main content

Bug Tracker

Side navigation

#1993 closed bug (fixed)

Opened November 30, 2007 10:52AM UTC

Closed December 03, 2007 09:43PM UTC

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:
Blocked by: Blocking:
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.

Attachments (0)
Change History (4)

Changed November 30, 2007 05:24PM UTC by davidserduke comment:1

need: ReviewTest Case
owner: → davidserduke
status: newassigned

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

if ( jQuery.isFunction( jQuery.data(element, "handle") ) )
  val = jQuery.data(element, "handle").apply(element, data");

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.

Changed December 01, 2007 05:26PM UTC by pwoldberg comment:2

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.

Changed December 01, 2007 06:29PM UTC by davidserduke comment:3

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.

Changed December 03, 2007 09:43PM UTC by davidserduke comment:4

need: Test CaseReview
resolution: → fixed
status: assignedclosed

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.