I need to know if it is possible to do this. I have an MVC app where I loop through some data and output a form for each object. On the form submit for an item, it posts to the server and returns an updated view. I want to replace the current html with the new view data.
The problem is I cannot figure out how to get a parent, child or specific element within the context of the form that was submitted on the Success function. I’ve also tried $(this).parent, $(this).child etc. Its seeing the form as an object, not an html element so I guess these query functions are not working on it.
Is it possible to do this or do I need to add some type of hack where I can just get a unique element id in the Success function, instead of trying to use $(this)?
<script type="text/javascript">
$(function () {
$("#form").live("submit", function (e) {
$.post($(this).attr("action"),
$(this).serialize(),
function (response) {
var form = $(this);
var container = $("#itemContainer", form);
container.html(response);
});
e.preventDefault();
});
});
</script>
jQuery.proxy