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

The Archive Base Latest Questions

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

I have a scaffold called post which has a title and a description. On

  • 0

I have a scaffold called post which has a title and a description. On my layout I have a link to create a new post that has :remote => true. How would I make it when I click on that remote link to change the content of a div so that I can create a new post?

  • 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-23T06:25:46+00:00Added an answer on May 23, 2026 at 6:25 am

    Let’s suppose the action you will use is called new.
    You should create a file called new.js.erb into views/posts that will be rendered when you post remotely your form. That file must include the javascript that places the new post into the div you want to fill. As an example, it could contain

    # new.js.erb
    $('div#container').html("<p><%= escape_javascript(@post.title) %></p>").append("<p><%= escape_javascript(@post.content) %></p>"); 
    

    The javascript will be executed immediately after the ajax post is finished and the new post is created. Remember the following:
    – You have to include jQuery
    – You have to specify in posts_controller the ability to render .js format, something like

    # posts_controller.erb
    def create
        @post = Post.new(params[:post])
    
        respond_to do |format|
          if @post.save
            format.html { redirect_to(@post, :notice => 'Post created via non AJAX.') }
            format.js # the actual ajax call
          else
            format.html { render :action => "new" }
          end
        end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a controller called 'exposures' which I created automatically with the script/generate scaffold
I have used Subsonic ORM in ASP.NET. It has Scaffold user control that generates
I have a rails model called 'audioclip'. I orginally created a scaffold with a
In my local machine i have a scaffold that uses Jquery Validation plugin for
I have 2 controllers that I created using scaffold generator of rails. I wanted
I have a brand new Rails 3.1rc4 project. After generating a scaffold, migrating and
I have a Page scaffold that I created through rails generate scaffold. I ran
I have scaffold with 2 fields name:string, active:boolean.. This way scaffold create data... def
I have a project with an Article scaffold - which includes a paperclip file
I have devise + a scaffold house created, and I want that a user

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.