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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:08:39+00:00 2026-05-20T06:08:39+00:00

My target result is when a user clicks a link, to have that pop

  • 0

My target result is when a user clicks a link, to have that pop up an overlay that contains a new page loaded from the server with AJAX.

The way I’m doing this is using Prototype Overlay (I’m using Prototype for AJAX) to create the dialog, and after the dialog is created, I’m calling:

new Ajax.Updater("div_inside_the_dialog",
                 "url_for_the_content",
                 {method: 'get', requestHeaders:{Accept:'text/javascript'}});

I also added into my url_for_the_content controller:

respond_to do |format|
  format.js
  format.html
end

So when the link is clicked, it creates a dialog, my controller for url_for_the_content, which sees that I’m making a JavaScript request, and returns some stuff to display inside the dialog.

It works okay, but it strikes me as very odd that I had to manually code that I’m looking for a JavaScript return in the request header, and then what I return isn’t actually JavaScript, it’s just a bunch of html for the dialog.

On the other hand, I don’t want to create a special controller method just for this, because it’s not really its own action conceptually since it’s displaying the same thing as an existing action, just formatted differently. Also, I’d have to disable layouts for it, and I would never want users to be able to visit it directly, not inside an AJAX dialog.

Can anyone provide any feedback on how I’m approaching this whole process, on any part of what I’m doing?

  • 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-20T06:08:40+00:00Added an answer on May 20, 2026 at 6:08 am

    I am not too familiar with the way you are calling the Ajax updated but I prefer simply rendering forms via Ajax, which should also make it clearly why you would manually be coding in a request for a Javascript return in your request header. The way I usually do it is save a js.erb file in the views folder corresponding to your controller name. So in Views/(Controller_Name)/ I have a file called (Action_Name).js.erb which would look something as follows:

    $("div_to_update").update("<%= escape_javascript(render('updateform')) %>")
    

    Simply doing that will allow you to call any form that you want with AJAX. Similarly something like this allows you to simply update whatever content you need to in whichever way necessary. Hope this helps

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

Sidebar

Related Questions

(The target browser is IE8) I have a div that contains a list of
In my ASP.Net application I have a requirement that when a user clicks on
I have a that has a list of checkboxes and user can click any
I have two types of links that are event-bound. If the clicked-on link has
The target machine is running Ububtu server 8.04. Here's the tramp output: tramp: Opening
Is it possible to target Windows Mobile 6 Professional and Standard from one project?
I've got an ASP.NET page that takes a long time to download and returns
My Windows Forms app collects data from user input and mathematical calculation and outputs
I have a form which, when the button gets clicked by a user, redirects
I have some items for sale that have 2 and 3 levels of customization.

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.