Skip to main content

Bug Tracker

Side navigation

#3112 closed bug (fixed)

Opened July 01, 2008 02:25PM UTC

Closed July 09, 2008 09:38PM UTC

Last modified July 10, 2008 03:15PM UTC

Special Events Data

Reported by: mike.helgeson Owned by: flesler
Priority: major Milestone: 1.3
Component: event Version: 1.2.6
Keywords: Cc:
Blocked by: Blocking:
Description

I would like to request that the special event setup function calls get passed the data parameter as a means to configuring the special event. The change would be made on line 1883 of 1.2.6:

if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) {

would become

if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem,data) === false ) {
Attachments (0)
Change History (7)

Changed July 01, 2008 03:25PM UTC by flesler comment:1

need: ReviewTest Case

Note that data can is undefined most of the time, and it is shared for all the events bound together.

Can you provide a situation where this is useful ?

Changed July 01, 2008 03:55PM UTC by mike.helgeso comment:2

I have a special event implementation of the "hoverIntent" plugin, and there are two options that are configurable (delay,speed). Currently, these options are only configurable document wide as they are attributes of the special event object. By leveraging the data parameter into the special event setup, I can extract custom settings within the setup function. The setup attaches mouseenter and mouseleave handlers and already uses the data param internally to share variables between the handlers. Personally, I don't plan on customizing the settings of this event per call, but such a small change would open a lot of possibilities. I understand that the data object is shared by all of the bound events, and while that may be a pitfall for some, I think it could also be cleverly powerful. In reality, it will most likely not be used by many developers, because as you said, data is undefined most of the time.

Changed July 02, 2008 02:45PM UTC by flesler comment:3

need: Test CasePatch
owner: → brandon

I'll let Brandon decide on this (he's busy right now) as he added the special events feature.

Changed July 09, 2008 09:35PM UTC by flesler comment:4

need: PatchCommit
owner: brandonflesler
priority: trivialmajor
status: newassigned
type: enhancementbug

Actually, this is a bug.

Right now, it isn't possible to bind data to any special special.

Changed July 09, 2008 09:38PM UTC by flesler comment:5

resolution: → fixed
status: assignedclosed

Fixed at [5777].

Changed July 09, 2008 10:07PM UTC by flesler comment:6

Actually, binding 'data' to a mouseenter/mouseleave was working without this change.

As the data goes with the handler.

Still, this is a small change, I see no need to revert for now.

Changed July 10, 2008 03:15PM UTC by mike.helgeso comment:7

Right, you are correct that the data always gets passed to the event handler, and there was never any problem with passing the data to special events. By additionally passing the data to the special event setup function, we are not fixing a bug, but opening up the possibility of more advanced event customization though this data transmission, without the need to make any other api changes.