Partial View Not Working Propely In Index View.
I am developing MVC application and using razor syntax. In this application I am giving comment facility. I have added a partial view, which loads the comment/Records from DB. In b
Solution 1:
To expand on what Alberto León is saying, the partial page load will not cause the document ready event to fire, so the re-rendered elements will not have the javascript event handlers registered after the first comment is added.
To resolve this, you could put the event registration code into a function, and call this both from the document ready event and the success handler of the AJAX call. Something like this:
functionAssignEventHandlers() {
$('a.addremark').click(function () {
....
});
$("a.pagenumber").click(function () {
var page = 0;
page = parseInt($(this).attr("id"));
$.ajax({
url: '@Url.Action("GetPagedCustomers")',
data: { "page": page },
success: function (data) {
$("#customerlist").html(data);
AssignEventHandlers();
}
});
returnfalse;
});
}
$(document).ready(function () {
$('.RemarkBox').hide();
AssignEventHandlers();
}
Post a Comment for "Partial View Not Working Propely In Index View."