开发者

Partial view render order with Jquery

开发者 https://www.devze.com 2023-03-18 02:40 出处:网络
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 th

I have two questions on the render order of the partial view

  1. 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?
  2. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消