I personally just download all the content using my own wrappers around $ .post, and initialize the content if necessary. It also helps to unify error handling, pending notifications, etc.
Third-party libraries usually provide a way to pre-process the content downloaded by ajax.
Partial views will not call document.ready, but they will evaluate scripts inside script tags in the head, so you can force calls with partial views.
Another way I use are custom html tags for forms. For example.
<form custom-setup="MyCustomSetupFunc">
and my $ .post handler checks this tag and calls this function, passing an instance of the form. This helps to narrow the scope of the script during partial loading (useful when multiple instances of a partial file can be loaded on the same page).
queen3
source share