Bug Tracker

Opened 10 years ago

Closed 9 years ago

#5563 closed bug (invalid)

Multiple instances of the same function on an event with different namespaces

Reported by: Ansman Owned by: brandon
Priority: minor Milestone:
Component: event Version: 1.3.2
Keywords: needsreview event namespace Cc:
Blocked by: Blocking:

Description

I was trying to make one element have multiple events of the same function like so:

$('#foo').bind('click.a', bar);
$('#foo').bind('click.b', bar);

This is, however, not possible in jQuery, even though they are in different namespaces. I do not know if this is intended or not but either way I think it needs to be fixed.

A temporary solution is to assign anonymous functions:

$('#foo').bind('click.a', function(e){ bar(e); });
$('#foo').bind('click.b', function(e){ bar(e); });

Change History (2)

comment:1 Changed 10 years ago by Ansman

I can also add that the functions where to have different data, otherwise this would not be an issue.

What i was trying to do:

$('#foo').bind('click.a', data1, bar);
$('#foo').bind('click.b', data2, bar);

comment:2 Changed 9 years ago by dmethvin

Keywords: needsreview added
Resolution: invalid
Status: newclosed

I'm going to mark this working as intended, in most cases you'd want to pass different data for the same function so you could tell the instances apart.

Note: See TracTickets for help on using tickets.