Bug Tracker

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#3112 closed bug (fixed)

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 ) {

Change History (7)

comment:1 Changed 15 years ago by flesler

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 ?

comment:2 Changed 15 years ago by mike.helgeso

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.

comment:3 Changed 15 years ago by flesler

need: Test CasePatch
Owner: set to brandon

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

comment:4 Changed 15 years ago by flesler

need: PatchCommit
Owner: changed from brandon to flesler
Priority: trivialmajor
Status: newassigned
Type: enhancementbug

Actually, this is a bug. Right now, it isn't possible to bind data to any special special.

comment:5 Changed 15 years ago by flesler

Resolution: fixed
Status: assignedclosed

Fixed at [5777].

comment:6 Changed 15 years ago by flesler

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.

comment:7 Changed 15 years ago by mike.helgeso

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.

Note: See TracTickets for help on using tickets.