I have added a row to a grid in jQuery success function, like this(edited adding Rob and Fleix comments):
$(function() {
$('#MyGrid').delegate('a.remove', 'click', function() {
alert("del");
// e.preventDefault();
jQuery.ajax(
{
type: "POST",
url: "Upload/Remove",
data: "removefile=" + stringhtml// error console shows it as undefined
});
$(this).closest('tr').remove();
});
$("#uploadForm").ajaxForm({
iframe: true,
dataType: "xml",
url: "Upload/Index",
success: function(result) {
('#MyGrid tbody').append('<tr><td> ' + stringhtml+ ' </td><td><a href="#"
class="remove">Remove</a></td></tr>');
});
});
the ajax call is not making for remove click ,but is hitting once page is loaded. How to make the ajax call for remove click, with passing the stringhtml?
Could you guys help me out!
thanking you,
michaeld
Bind to the click event of the remove links
Change your row append code to