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 6045279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:06:25+00:00 2026-05-23T07:06:25+00:00

I am a newbie developing using rails and jquery and having been searching everywhere

  • 0

I am a newbie developing using rails and jquery and having been searching everywhere for a simple example of how to do this for days. I have a page, poweroutput.html.erb, that shows the power output of a customer’s solar power system for a particular date. When they input a different date, I want them to see different output, but without having to reload the page. On my page I have some javascript as well as a form (for submitting the date for which a user would like to see the power output) as follows:

<head>
  <script type="text/javascript">
    <%= render "pages/poweroutputscript" %>  # renders a partial containing all my js
  </script>
</head>

# a form is here on this page too

My page’s controller action is currently as follows:

def poweroutput      
  # some code 

  if request.xhr?
    @date = params[:dt]         # dt is posted when form is submitted
  else 
    @date = Time.now.getlocal.strftime("%d.%m.%Y")
  end

  respond_to do |format|
    format.html 
    format.js { render :action "pages/poweroutput.js.erb" }
  end
end

And poweroutput.js.erb is as follows:

$("script").html("<%= escape_javascript render "pages/poweroutputscript" %>");

As is, the form submits successfully and I can see on Firebug that the js between my script tags is indeed being replaced with the new js. But the view in my browser is not updating accordingly. What am I doing wrong?

  • 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-23T07:06:26+00:00Added an answer on May 23, 2026 at 7:06 am

    I don’t think replacing the content of the <script> tag will cause it to run. Try this:

    $("script").replaceWith("<script><%= escape_javascript render "pages/poweroutputscript" %></script>");
    

    or just create a new <script> and add it to your document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm newbie at web developing. i have some input form.i'm using jquery 1.4.2 inside
Having some problems with a site I'm developing for a friend. I've been using
I am a newbie to the programming world. I have experiences of developing simple
I am not just a newbie with Javascript. I am developing a simple site
I am a newbie and developing a website using ASP .Net 2.0 with C#
I'm a newbie developing my second project in Ruby on Rails: A graphic calculator.
I'm a Rails newbie, and I was initially using NetBeans + JRuby to make
I'm developing WinForms application using VS2010. I have about 15 projects in the solution.
A total newbie question.... I am developing a Joomla template and in this I
I'm newbie in developing apps for smartphones, but have lots of experience writing desktop

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.