How should javascript in an ajax loaded partial view be handled?
问题 In ASP.NET MVC, what is the preferred pattern for running Javascript on a partial view that is loaded via Ajax? For example, suppose you need to wire up some click events in your partial view. Of course, putting something like this in the partial view would not work, because the document ready event won't fire after the partial view is Ajax loaded. <script type="text/javascript"> $(function() { $("a.foo").click(function() { foo(); return false; }); }); </script> I suppose something like this