Bug Tracker


Ticket #4128 (closed bug: worksforme)

Opened 5 years ago

Last modified 3 years ago

live function doesn't work on current elements

Reported by: selimachour Owned by: selimachour
Priority: undecided Milestone: 1.3.2
Component: event Version: 1.3.1
Keywords: Cc:
Blocking: Blocked by:


I've been trying everything to get the current <a class="foo">s to work with the $('a.foo').live('click', bar) with no luck.

The <a class="foo">s loaded via ajax do get the event handler properly attached, but not the current ones.

My work around is

$('a.foo').click(bar).live('click', bar);

is that normal ? Do you need an example ?


live2.tar.gz Download (94.4 KB) - added by selimachour 5 years ago.
live() issue example

Change History

comment:1 Changed 5 years ago by dmethvin

Can you provide a test case?

comment:2 Changed 5 years ago by selimachour

Sure, I'll get an example ready for you

In the mean time, I noticed that ...

<a href="xxx" class="foo" custom_attribute="custom_value">zzzz</a>

... did not receive the event either even though it was loaded via ajax. Removing the custom attribute fixed that.

Changed 5 years ago by selimachour

live() issue example

comment:3 Changed 5 years ago by selimachour


I attached a minimized version of our website.

The website js code is in behaviors.js, all the rest are just misc. plugins.

I left the navigation on the left side and a menu on the right side. They're both made of <a class="js_link_internal">....</a>

$('a.js_link_internal').live(click, jsLinkInternal') should turn both set of links into ajax calls except it does not do it for the navigation links.

It looks like the "$('#A').click(function)" call is the issue...

Any help would be very appreciated.

comment:4 Changed 3 years ago by rwaldron

  • Keywords needsreview added
  • Owner changed from brandon to selimachour
  • Status changed from new to pending
  • Priority changed from major to undecided

Please provide a reduced jsFiddle test case, thanks!

Additionally, test against the jQuery 0 GIT version to ensure the issue still exists.

comment:5 Changed 3 years ago by aboushley

Created a fiddle that I think follows the situation described (except that I just have a link to add more links, not using ajax). The fiddle is located at  http://jsfiddle.net/9HRgE/1/. This fiddle does not exhibit the behaviors described. I tested with the 1.3.2 version and it also seems to work fine there, jsfiddle does not however have 1.3.1 so I couldn't test that version.

comment:6 Changed 3 years ago by dmethvin

  • Keywords needsreview removed
  • Status changed from pending to closed
  • Resolution set to worksforme

Works in 1.3.2 all the way up to the current version.

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


Add a comment

Modify Ticket

as closed

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

Note: See TracTickets for help on using tickets.