Bug Tracker

Modify

Ticket #2223 (closed bug: invalid)

Opened 5 years ago

Last modified 15 months ago

triggerHandler triggers only on the first selected element

Reported by: joern Owned by:
Priority: major Milestone: 1.2.4
Component: event Version: 1.2.2
Keywords: Cc:
Blocking: Blocked by:

Description

For some reason triggerHandler triggers handlers only on the first selected element. As I see no apparent reason for that behaviour, and the docs say nothing about it, I consider it a bug.

Actually the docs say triggerHandler would reuturn a jQuery object, which it doesn't.

The obvious patch would be to add the usual each:

triggerHandler: function( type, data, fn ) {
	return this.each(function(){
		jQuery.event.trigger( type, data, this, false, fn );
	});
},

I'm rather sure there is something else behind this...

Change History

comment:1 Changed 5 years ago by scott.gonzal

I think the behavior is intended and the docs are just misleading. triggerHandler currently returns the value returned by the handlers (for the first element). Obviously the current implementation and the suggested implementation are both useful.

I use the current implementation in the webforms plugin as:

if ($(elem).triggerHandler('invalid') !== false) {
    $.webForms.errorHandler(elem);
}

However, this could be accomplished using internal jQuery code as:

if ($.event.trigger('invalid', null, elem) !== false) {
    $.webForms.errorHandler(elem);
}

I would assume that other developers are taking advantage of the current return value as well.

comment:2 Changed 5 years ago by flesler

  • Component changed from core to event
  • Milestone changed from 1.2.3 to 1.2.4

comment:3 Changed 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.