开发者

Partial view render order with Jquery

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜