I like to stash id's and similar metadata in "data-" attributes on the dom elements that represent those objects.
In this case I will usually use a similar setup
<ul class="posts">
<li class="post" data-post="####">
<p>content...</p>
<ul class="actions">
<li>
<a class="delete">delete</a>
</li>
</ul>
</li>
</ul>
Then in an .js file included at the bottom of the page:
$('.posts').on('click', '.actions .delete',
function() {
// which post should be deleted?
var $post = $(this).closest('.post');
// remove the DOM element
$post.remove();
// some sort of ajax operation
$.ajax({
// url, dataType, etc
data: { post_id: $post.data('id') }
});
});
This one handler will apply to all ".action .delete" elements in the main list, meaning that if you want to add a loader or pagination that uses ajax to modify or add times to the list, the one event handler will still work wonderfully.