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

  • SEARCH
  • Home
  • 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 5944741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:34:56+00:00 2026-05-22T16:34:56+00:00

I have jQuery loading correctly on Rails 3, and the $(document).ready() event never gets

  • 0

I have jQuery loading correctly on Rails 3, and the $(document).ready() event never gets run. I know this because I tried running the code within the $(document).ready(); manually via Google Chrome’s Javascript Console and it ran just fine.

I’m not sure at all what’s wrong, so I thought I’d ask StackOverFlow

Please note that the ERB/HTML isn’t of good quality yet. I’m just learning this.

Here’s the ERB:

<html>
    <head>
        <style type="text/css">
            #Agenda
            {
                background-color: #36175E;
                width: 960px;
                margin: 0 auto;
                text-align: center;
            }
            #assignment
            {
                background: green;
                width: 600px;
                height: 500px;
                float: right;
                margin: auto;

            }
            #accordion
            {
                margin: auto;
                width: 350px;
                height: 500px;
                float: left;
            }


        </style>
        <script type="text/javascript">
            $(document).ready(function(){
                $('#accordion').accordion();
                SetupAccordionItems();
                });


            //This is probably not the best way to do it
            $('li[id]').click(function(e)
            {
                SetupAssignment(this.id);
            });

            function SetupAssignment(Assignment_ID) 
            {
                if (Assignment_ID != null)
                {
                    $('#ShowAssignmentInstructions').fadeOut('slow');
                    document.getElementbyID(ShowAssignmentInstructions).visibility = "hidden";
                    var Assignment = "BAEGLS";
                    document.getElementbyID(Assignment_Name).InnerText = Assignment.name;
                    document.getElementbyID(Due_Date).InnerText = Assignment.due_date;
                    if (Assignment.image == null)
                    {
                        Assignment.image = Assignment.Unit.Image;
                    }
                    document.getElementbyID(Assignment_Image).src = Assignment.Image;
                    //Resets contents of the paragraph describing the assignment
                    document.getElementByID(basic_assignment_info).InnerText = null;
                    document.getElementbyID(basic_assignment_info).InnerText = "This assignment is worth " + Assignment.DefaultMaximumPoints + "points.";
                    document.getElementbyID(assignment).style.visibility = "visibility";
                    document.getElementbyID(Assignment_Status).src = Assignment.Status;
                }
                else
                {
                    $('#ShowAssignmentInstructions').fadeIn('slow');
                }
            }
            function SetupAccordionItems()
            {
                var AssignmentsDueNextSchoolDay = <%= GetByDueDateForCurrentUser(@nextSchoolDay) %>;
                var AssignmentsDueNextNextSchoolDay = <%= GetByDueDateForCurrentUser(@nextNextSchoolDay) %>;
                var AssignmentsDueNextNextNextSchoolDay = <%= GetByDueDateForCurrentUser(@nextNextNextSchoolDay) %>;

                for (assignment in AssignmensDueNextSchoolDay)
                {
                    AppendAccordionItem(Assignment, "DueInOneSchoolDay");
                }
                for (Assignment in AssignmentsDueNextNextSchoolDay)
                {
                    AppendAccordionItem(Assignment, "DueInTwoSchoolDays");
                }
                for (Assignment in AssignmentsDueNextNextNextSchoolDay)
                {
                    AppendAccordionItem(Assignment, "DueInThreeSchoolDays");
                }

            }
            function AppendAccordionItem(Item, ID)
            {
                $("<li>", {id:Item.ID, text:Item.Name}).appendTo(ID);
            }

        </script>
    </head>

    <body>


        <div id="Agenda">
            <h1 id="Agenda_Title">Agenda</h1>
            <div class="accordion" id="accordion">

                <h3 id="TomorrowsDate"><%= @nextSchoolDay %></h3>
                <ul id="DueInOneSchoolDay">

                        </ul>
                    <h3 id="DueDayAfterTomorrow_Title"><%= @nextNextSchoolDay %></h3>
                    <div>
                        <ul id="DueInTwoSchoolDays">
                         </ul>
                    </div>
                    <h3 id="DueDayAfterDayAfterTomorrrow_Title"><%= @nextNextNextSchoolDay %></h3>
                     <ul id="DueInThreeSchoolDays">
                         </ul>


            </div>
            <div id="assignment" display="hidden">
                <h2 id="Assignment_Name"><center>Assignment Name</center></h2>
                <h3 id="Due_Date"><center>Due Date</center></h3>
                <img id="Assignment_Image" src="#"/>
                <br>
                <button id="Start_Assignment">Start Assignment</button>
                <p id="basic_assignment_info">
                </p>
                <img id="Assignment_Status" src="#"/>
            </div>

        </div>
    </body>
</html>

Here’s the HTML outputted by the ERB

<html>
    <head>
        <style type="text/css">
            #Agenda
            {
                background-color: #36175E;
                width: 960px;
                margin: 0 auto;
                text-align: center;
            }
            #assignment
            {
                background: green;
                width: 600px;
                height: 500px;
                float: right;
                margin: auto;

            }
            #accordion
            {
                margin: auto;
                width: 350px;
                height: 500px;
                float: left;
            }


        </style>
        <script type="text/javascript">
            $(document).ready(function(){
                $('#accordion').accordion();
                SetupAccordionItems();
                });


            //This is probably not the best way to do it
            $('li[id]').click(function(e)
            {
                SetupAssignment(this.id);
            });

            function SetupAssignment(Assignment_ID) 
            {
                if (Assignment_ID != null)
                {
                    $('#ShowAssignmentInstructions').fadeOut('slow');
                    document.getElementbyID(ShowAssignmentInstructions).visibility = "hidden";
                    var Assignment = "BAEGLS";
                    document.getElementbyID(Assignment_Name).InnerText = Assignment.name;
                    document.getElementbyID(Due_Date).InnerText = Assignment.due_date;
                    if (Assignment.image == null)
                    {
                        Assignment.image = Assignment.Unit.Image;
                    }
                    document.getElementbyID(Assignment_Image).src = Assignment.Image;
                    //Resets contents of the paragraph describing the assignment
                    document.getElementByID(basic_assignment_info).InnerText = null;
                    document.getElementbyID(basic_assignment_info).InnerText = "This assignment is worth " + Assignment.DefaultMaximumPoints + "points.";
                    document.getElementbyID(assignment).style.visibility = "visibility";
                    document.getElementbyID(Assignment_Status).src = Assignment.Status;
                }
                else
                {
                    $('#ShowAssignmentInstructions').fadeIn('slow');
                }
            }
            function SetupAccordionItems()
            {
                var AssignmentsDueNextSchoolDay = <%= GetByDueDateForCurrentUser(@nextSchoolDay) %>;
                var AssignmentsDueNextNextSchoolDay = <%= GetByDueDateForCurrentUser(@nextNextSchoolDay) %>;
                var AssignmentsDueNextNextNextSchoolDay = <%= GetByDueDateForCurrentUser(@nextNextNextSchoolDay) %>;

                for (assignment in AssignmensDueNextSchoolDay)
                {
                    AppendAccordionItem(Assignment, "DueInOneSchoolDay");
                }
                for (Assignment in AssignmentsDueNextNextSchoolDay)
                {
                    AppendAccordionItem(Assignment, "DueInTwoSchoolDays");
                }
                for (Assignment in AssignmentsDueNextNextNextSchoolDay)
                {
                    AppendAccordionItem(Assignment, "DueInThreeSchoolDays");
                }

            }
            function AppendAccordionItem(Item, ID)
            {
                $("<li>", {id:Item.ID, text:Item.Name}).appendTo(ID);
            }

        </script>
    </head>

    <body>


        <div id="Agenda">
            <h1 id="Agenda_Title">Agenda</h1>
            <div class="accordion" id="accordion">

                <h3 id="TomorrowsDate"><%= @nextSchoolDay %></h3>
                <ul id="DueInOneSchoolDay">

                        </ul>
                    <h3 id="DueDayAfterTomorrow_Title"><%= @nextNextSchoolDay %></h3>
                    <div>
                        <ul id="DueInTwoSchoolDays">
                         </ul>
                    </div>
                    <h3 id="DueDayAfterDayAfterTomorrrow_Title"><%= @nextNextNextSchoolDay %></h3>
                     <ul id="DueInThreeSchoolDays">
                         </ul>


            </div>
            <div id="assignment" display="hidden">
                <h2 id="Assignment_Name"><center>Assignment Name</center></h2>
                <h3 id="Due_Date"><center>Due Date</center></h3>
                <img id="Assignment_Image" src="#"/>
                <br>
                <button id="Start_Assignment">Start Assignment</button>
                <p id="basic_assignment_info">
                </p>
                <img id="Assignment_Status" src="#"/>
            </div>

        </div>
    </body>
</html>
  • 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-22T16:34:57+00:00Added an answer on May 22, 2026 at 4:34 pm

    First you need to import jquery file like this.

    <script type="text/javascript" src="jquery-1.4.1.js"></script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some content that I am loading using jquery ajax. The content has
I have an ASP.NET MVC view on which I've placed jQuery tabs. I'm loading
I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody
Say I have jquery code like this: html += '<div class=index>' + item.index +
I keep getting this error all over the place where I only have jquery
I have following code on my site: backgroundImages[bg_img_path_b]=new Image(); backgroundImages[bg_img_path_b].src = bg_img_path_b; backgroundImages[bg_img_path_b].loaded=loading; //jQuery(backgroundImages[lastImage]).unbind('load.backgroundImages');
I have this code that I run when a user submits a form (this
I have an ajax call in jQuery loading some elements into a div. The
Anyone have any experience using the thickbox jquery plugin? I have it setup correctly,
I have jQuery to select all font elements that are children of the element

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.