I have been searching around the web and reading articles for nearly a week on this topic, but I apologize if it has already been answered somewhere that I may have overlooked.
I have a (potentially) interesting case where I have an ASP.NET MVC4 (Razor) project that I have created and I would like some jQuery that is loaded and executes on my parent view to be able to manipulate objects on the partial view.
When I call my partial view like this, everything works dandy:
@{Html.RenderPartial("TicketList", "Home");}
However, I need the ability to reload this partial's data inside the parent on-demand; thus, I am using this code to call the partial:
<div id="ticketList"></div>
<script>
function updateTickets() {
$.ajax({
url: '@Url.Action("TicketList", "Home")',
dataType: "html",
success: function (result) {
$("#ticketList").html(result);
}
});
}
updateTickets();
</script>
My dilemma is that with the first piece of code - the Partial renders great... All jQuery from the parent view executes as expected; however, with the second method, the jQuery will not execute. It is as if the parent jQuery doesn't recognize the new code that has been loaded via the partial.
Maybe I'm going about this the wrong way... but any help or advice would be immensely appreciated!
Many thanks :)