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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:06:36+00:00 2026-05-26T06:06:36+00:00

When the user is clicking on a link with the class edit_resource, the content

  • 0

When the user is clicking on a link with the class “edit_resource”, the content of a div should be replaced by a partial. Here is my code:

$(".edit_resource").click(function(){
  var id = $(this).attr("id")
  $('#id' + id + '_show').html("<%= escape_javascript(render :partial => 'form', :locals => {:@resource => resource})%>")
})

The code is working as expected, except that that escape_javascript doesn’t work. The new content of the div is the text

<%= escape_javascript(render :partial => ‘form’, :locals => {:@resource => resource})%>

, and this is also what is shown on the page.

No code is executed, and my partial isn’t rendered. I have tried to use <%== instead of <%= without luck.

I have also tried

<%= raw escape_javascript(render :partial => ‘form’, :locals => {:@resource => resource})%>

I have even tried to replace the partial part of the code with just simple rails code. That didn’t help either.

What can I do?

I use Rails 3.0.10, and my javascript_include_tag is like this:

<%= javascript_include_tag ‘jquery-1.6.2.min’, ‘jquery-ui-1.8.16.custom.min’, ‘application’, ‘jquery.rails.js’%>

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

    I have put my js in a js.erb-file, and finally managed to use my variables in the right way.

    Here’s my code:

    $('#id' + '<%= @id %>' + '_show').html('<%= escape_javascript(raw render :partial => 'form', :locals => {:@resource => Resource.find_by_id(@id)}).html_safe %>')
    

    And in the controller:
    format.js { @id = params[:id]}

    In the view: <%= link_to t(‘edit’), resources_path(:id => resource.id), :remote => true %>

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

Sidebar

Related Questions

Here is the JQuery: $(document).ready(function() { $('#autosave').click(function() { var url = window.location.pathname; $postData =
How do I show a div class on clicking a link? This is the
I have a user control with a More Info link. When clicking that link,
@editLinks = $ie.link(:text => Edit, :class =>edit ).links @editLinks.each do |l| l.click end I
I have a 'link' that, when clicked, will show a div full of content.
I need to find whether the user clicking the browser back button or Refresh
i need to check whether the user clicking the browser Refresh button and redirect
I'm trying to delete the messages which is selected by user by clicking the
User can switch active application by Alt+Tab or by clicking on their icons in
After clicking on a UIView I want to take the user of my app

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.