Bug Tracker

Opened 15 years ago

Closed 15 years ago

Last modified 11 years ago

#2340 closed bug (fixed)

[UI] Dispatched Events

Reported by: scottgonzalez Owned by: scottgonzalez
Priority: major Milestone: 1.2.4
Component: ui Version: 1.2.3
Keywords: ui event Cc:
Blocked by: Blocking:


There are currently three models being used for dispatching events in the UI plugins.


$(el).triggerHandler('<action>.ui-<plugin>', [ui], callback);

dialog, draggable, droppable, resizable, selectable, slider, sortable

$(el).triggerHandler('<plugin><action>', [e, ui], callback);


$(el).triggerHandler('<action>.ui-<plugin>', [ui]);

The accordion and tabs models are both missing the event object in the data parameter. The tabs model is also missing the callback.

However, it is unclear which event naming convention should be used. The more widely used "<plugin><action>" convention seems more likely to avoid collisions with other event names. However, the "<action>.ui-<plugin>" convention provides the convenience of having user-defined events be cleaned up if the plugin's destroy method is called.

Change History (9)

comment:1 Changed 15 years ago by joern

Unless you actually need to provide a custom event object - for whatever reason - there is no point in passing one in.

Passing in the callback has now obvious drawbacks, that should be easy to fix for tabs.

Not sure about the namespace though.

comment:2 Changed 15 years ago by scott.gonzal

You're right about not needing to pass in the event object. I forgot that the parameters passed to the event handler will still be (event, ui) regardless of whether the plugin passes an event object in the data. My concern was only that the user would have different parameters to work with depending on the plugin (apparently I didn't think it through far enough).

comment:3 Changed 15 years ago by paul

Yes, we should definitely make sure we have one convention for naming the custom events. From a semantical view, I would prefer <plugin><action>.

However, I right now tend to go with the dot, since it feels more like it was intended.

comment:4 Changed 15 years ago by paul

Status: newassigned

comment:5 Changed 15 years ago by scott.gonzal

Recent thoughts on why <plugin><action> might be better than <action>.ui-<plugin>:

1) Event names may overlap with real events. For instance, "slidechange" would become "change.ui-slider" which could end up being triggered from some other change event.

2) If someone develops widgets that rely on jQuery UI plugins, they may want to hook into the events and use their own namespace (to make cleanup easier). This will only be possible if the triggered events are not namespaced.

comment:6 Changed 15 years ago by paul

Owner: changed from paul to scott.gonzalez
Status: assignednew

Scott, I vote for <plugin><action>. I've assigned it to you - could you work on this later on in every plugin?

comment:7 Changed 15 years ago by scott.gonzal

Status: newassigned

Accordion is fixed in [4912].

comment:8 Changed 15 years ago by scott.gonzal

Tabs updated in [4956] - Thanks Klaus.

comment:9 Changed 15 years ago by scott.gonzal

Resolution: fixed
Status: assignedclosed

datepicker currently has no events

Note: See TracTickets for help on using tickets.