Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#8596 closed bug (invalid)

Event $(this).bind conflict with $(this).trigger

Reported by: [email protected] Owned by:
Priority: undecided Milestone: 1.next
Component: event Version: 1.5.1
Keywords: Cc:
Blocked by: Blocking:


There seems to be a conflict when trying to trigger an event that has the same name as a function in a custom javascript object. Example:

var Class = {

construct: function() {

$("body").bind("click", $.proxy(this, "onBodyClick"));

}, onBodyClick: function(e) {




The above code will create a loop and the "onBodyClick" function will run over and over again. Not sure what this has to do with, but I've been creating a pretty decent sized application powered by jquery and this error has caught me a few times.

Change History (3)

comment:1 Changed 12 years ago by anonymous

Here is the link to the jsfiddle example. http://jsfiddle.net/earl3s/zLeYa/

comment:2 Changed 12 years ago by Rick Waldron

Component: unfiledevent
Resolution: invalid
Status: newclosed

The problem is not jQuery, but that you have misunderstood how you're passing context with the $.proxy call. When I look at your code and I see the result in the console, that's exactly what I expect to see.

comment:3 Changed 12 years ago by [email protected]

Really? I can accept that. Could you explain why it's happening that way? I thought I was triggering an event, but it seems like it's actually calling a function with that name (and triggering the event). If it's a scope issue with the proxy can you help me understand what is going on there?


Note: See TracTickets for help on using tickets.