I have a scenario where jQuery 'on' and 'live' do not work the same way. Perhaps someone can indicate why. I am using jQuery 1.7.2 with my project, and in this assembly "live" is replaced by 'on'. I am using the following code on a list page. Basically, this page has an alphabetical panel that the user can click and download all clients with this last name. I would like the link to be done via ajax.
the code:
$("a.listajax").on("click", function (e) { e.preventDefault(); var url = $(this).attr("href"); $("div.content").load(url + " div.content"); return false; });
The problem here is that when I first load the page and click the link, everything works fine. The page loads through ajax. However, after that, all links lose their bindings, and then if I click on any links, I get the entire page load.
I replaced 'on' with "live", and the links began to behave perfectly, even with subsequent clicks.
What am I missing?
source share