I have links in a list that fires some jQuery activity:
HTML:
<div id="list">
<a href="#" rel="23" class="edit">Edit:</a> Foo
<a href="#" rel="24" class="edit">Edit:</a> Bar
etc.
jQUERY:
$('.edit').click(function(e) {
e.preventDefault;
...open edit form and save update with $.ajax to server...
...with $.ajax retrieve fresh list from database...
...use $('#list;).html(fresh list of links)...
});
First I tried the following to "rebind" the edit link to an event:
$('.edit').on('click', function(...
That didn't work. After reading this great answer, I tried:
$(document).on('click', '.edit', function(...
and bingo! It worked.
Question: Can someone explain the differences between the two?
Thanks.