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

The Archive Base Latest Questions

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

I have a Javascript where I render a partial using the js.erb : $(‘#registration-steps’).fadeOut(fast).html(<%=

  • 0

I have a Javascript where I render a partial using the js.erb:

$('#registration-steps').fadeOut("fast").html("<%= escape_javascript( render :partial =>   @page, :layout => false )%>").fadeIn("slow");

The problem is, in this partial I have some code from adwords I want to render for conversion tracking:

E.g:

<script type="text/javascript" src="https://www.googleadservices.com/pagead/conversion.js">

When I call the partial however, the script is being stripped and the javascript is not being executed.

I tried the following in my js.erb with no avail:

var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "https://www.googleadservices.com/pagead/conversion.js";
$("#tracking").append(script);
  • 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-28T18:44:44+00:00Added an answer on May 28, 2026 at 6:44 pm

    Try to dynamically execute the script using jQuery’s getScript function:

    http://api.jquery.com/jQuery.getScript/`

    However, that still means that the script include in your partial is mangled when you escape_javascript.

    As another possibility you could move the include out of your partial and add a content_for call to your layout:

    <% =content_for :ad_words %>
    

    Then at the end of your js.erb file I would insert it:

    <% content_for :ad_words do %>
         <script type="text/javascript" src="https://www.googleadservices.com/pagead/conversion.js">
    <% end %>
    

    That way there’s no longer a chance it will be escaped.

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

Sidebar

Related Questions

I have two partials _choose.html.erb and _details.html.erb. I render choose like so: <div id="choose"
I have javascript code embedded inside a html template file. When I load this
I have the following code. def add_resume_link(name, form) link_to_function name do |page| html =
I am appending code to a div block from a partial using unobtrusive javascript.
I have a problem while trying to render a partial action on my layout.
I have a partial that renders a select box using the following method: <%=
Can I render a partial by binding a function to a hyperlink? I have
I'm using Rails 3.0.3 I have this code in my Partial: <% tasks =
I am using the following partial to render the editor for the Create and
I want to create a link_to render :partial . I have two partials stored

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.