Find li on newly prepended item
<p>My application adds new posts to an <code>&lt;ul&gt;</code> using .prepend() and then uses the .ajax() function to add it to the database like so:</p>

<pre><code>$("#add input[type=submit]").click(function(){
    newPost = $("#add textarea").val();
    $.ajax({
        type    : "POST", 
        url     : "/add", 
        data    : { "post" : newPost },
        success: function(data) {               

           $('#posts ul').prepend('&lt;li id="1234"&gt;&lt;p&gt;'+newPost+'&lt;p&gt;&lt;span class="delete"&gt;Delete&lt;/span&gt;&lt;/li&gt;');
        }
});
</code></pre>

<p>This works as intended, but as you can see I have a Delete button for each post and I delete post using the following jquery:</p>

<pre><code>$(".delete").click(function(){
    var thiscache = $(this),
    post_id = thiscache.closest("li").find("p").attr("id");

    $.ajax({
        type    : "POST", 
        url     : "/delete", 
        data    : { "post_id" : post_id },

        success : function(r){ 
            thiscache.parent().slideUp('slow'); 
            },

    });
});
</code></pre>

<p>Delete will work with post that have been added previously, but if you add a post using the ajax form, and click delete nothing fires. What could be the cause of this? Maybe the new post <code>&lt;li&gt;</code> isn't in the DOM?</p>

<p>I created a JSfiddle without the Ajax functions. <a href="http://jsfiddle.net/bhhgf" rel="nofollow">http://jsfiddle.net/bhhgf</a>
If you add a new post it will append it, but you can not delete it. Deleting the current posting works just fine.</p>

<p>EDIT:</p>

<p>I also use jeditable with a custom event, but .live() will not tigger new post.</p>

<pre><code>$("p").editable('/edit/save', {event : 'edit_button'});

$(".edit").live('click', function(){       
    $(this).closest("li").find("p").trigger('edit_button');
});
</code></pre>
