I have two questions on the render order of the partial view
- If I have the $.ready(), $.live in the partial view, when are the initiated, in开发者_运维技巧 the initiation of this partial view or the whole document?
- I cannot reference a new css file on the partial view. Do I have to reference those style files in the layout?
You can have multiple $(document).ready() calls in the same document. Each $.ready() or $.live() are rendered in the same order that they appear in the code.
In your partial view you can dynamically insert your css script to the head of the page:
<script type="text/javascript">
$(document).ready(function() {
$('<link href="' + @Url.Content("~/Content/Site.css") + '" rel="stylesheet" type="text/css" />').appendTo('head');
});
</script>
Users may notice a slight delay for these styles to take effect after the DOM has loaded.
精彩评论