Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6140909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:10:44+00:00 2026-05-23T18:10:44+00:00

I have partials that get rendered as part of a complex page composition. Some

  • 0

I have partials that get rendered as part of a complex page composition.

Some of these partials need some jQuery OnDocumentReady goodness to seed list data etc.
There can be many of these partials chosen during a render (it’s very dynamic)

in my _Layout I have a section definition that looks like this

<script src="http://my/fav/cdn/jquery-1.5.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(function($) {
    @RenderSection("OnDocumentReadySection", false)
});
</script>

in my partials I want to write something like this

@section OnDocumentReadySection{
    $('#partial-1').init();
}

and have the result of the page render end up with something like this

<script src="http://my/fav/cdn/jquery-1.5.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(function($) {
    $('#partial-1').init();
    $('#partial-2').init();
    $('#partial-3').init();
    $('#partial-n').init();
});
</script>

This is to make sure all my javascript is at the bottom of the rendered html which I am told is far more optimal.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:10:44+00:00Added an answer on May 23, 2026 at 6:10 pm

    Instead of:

    jQuery(function($) {
        $('#partial-1').init();
        $('#partial-2').init();
        $('#partial-3').init();
        $('#partial-n').init();
    });
    

    You should instead assign each of them a common css class (even if you don’t define a definition for it) and then do this in the head:

    jQuery(function($) {
        $('.classname').init();
    });
    

    Or if need be:

    jQuery(function($) {
        $('.classname').each(function(){ $(this).init(); });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a partial view that is rendered inside of a JQuery dialog. I
I have some questions about some things in Asp.net MVC that still confuses me.
I need some advice. (For those who have already read this before I have
I have a partial view which gets rendered within a jQuery UI dialog. Because
I have several partials that I'm including in my Rails application.html.erb file , but
I have a simple table that is rendered in an MVC partial view and
I have a partial that renders a select box using the following method: <%=
I have a partial that I want to display in a layout only when
I have a partial view that I want to basically take care of itself
I have a partial view that is shared between two controllers and I'm trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.