Bug Tracker

Opened 10 years ago

Closed 8 years ago

#6161 closed bug (fixed)

ajaxComplete event does not fire when context is used

Reported by: rv4wd Owned by:
Priority: high Milestone: 1.next
Component: ajax Version: 1.4.4
Keywords: ajax, callbacks, events, context, ajaxrewrite Cc:
Blocked by: Blocking:


When you use an ajax request with a context, then the ajaxComplete, ajaxSuccess and ajaxError callbacks don't fire. I don't know, if this is intended, but it prevents usage of ajaxComplete as a global callback for all requests which have "global=true" in their settings.

Bound event: $('#messages').ajaxComplete(fn);

request: $.ajax({ url: '/ajax', global: true, context: customObject });

Change History (10)

comment:1 Changed 9 years ago by rv4wd


Bug still needs review ;)

comment:2 Changed 9 years ago by stimpson

same problem here, any ideas how to get around this?

comment:3 Changed 9 years ago by stimpson

workaround: use .proxy() to give the context to your callback-function

comment:4 Changed 9 years ago by snover

This happens because jQuery will trigger the “global” event on your context object if you have defined one instead of despatching it globally. This is intentional within the jQuery source but I don’t know why.

comment:5 Changed 9 years ago by snover

Keywords: context added
Milestone: 1.4.2
Priority: high
Status: newopen

comment:6 Changed 9 years ago by snover

#7017 is a duplicate of this ticket.

comment:8 Changed 9 years ago by Rick Waldron

Keywords: ajaxrewrite added

comment:9 Changed 8 years ago by danheberden

Milestone: 1.next

Still a valid bug in 1.5.2 RC1 - http://jsfiddle.net/danheberden/u7UvR/

comment:10 Changed 8 years ago by jaubourg

Resolution: fixed
Status: openclosed

@dan: the event bubbles properly: http://jsfiddle.net/st796/ , remember it's triggered on the context.

Now, back to the user's original use-case (using an OBJECT as a context), this has been fixed in 1.5.1 with these two commits:

See http://jsfiddle.net/qZEnv/ as a proof.

Note: See TracTickets for help on using tickets.