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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:55:17+00:00 2026-05-22T18:55:17+00:00

I am trying to preview a text area. But it dosnt work. My new.html.erb:

  • 0

I am trying to preview a text area. But it dosnt work.

My new.html.erb:

<h1>New post</h1>

<%= render 'form' %>

<%= link_to 'Back', posts_path %>

My form.html.erb:

<%= form_for(@post) do |f| %>
  <% if @post.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>

      <ul>
      <% @post.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :titel %><br />
    <%= f.text_field :titel %>
  </div>
  <div class="field">
    <%= f.label :body_html %><br />
    <%= f.text_area :body_html %>
  </div>
  <div class="field">
    <%= f.label :up_votes %><br />
    <%= f.text_field :up_votes %>
  </div>
  <div class="field">
    <%= f.label :down_votes %><br />
    <%= f.text_field :down_votes %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>
<div id="post-preview" style="width:400px;border:1px solid black; height:500px;"></div>

My new.js.erb:

$('#post-preview').html($('#post_body_html').val());
  • 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-22T18:55:18+00:00Added an answer on May 22, 2026 at 6:55 pm

    To me it seems like you need to bind the preview to something to be able to work:

    $(document).ready(function() {
        // Bind it to some action.
        $('.preview').click(function(){
            $('#post-preview').html($('#post_body_html').val());
        });
    });
    

    You can even bind it to keyboard pressing; like the one you see here on StackOverflow.

    Click event Working Example: http://jsfiddle.net/kuroir/D7cPT/1/
    Automatic refresh (on keyDown) working Example: http://jsfiddle.net/kuroir/D7cPT/3/

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

Sidebar

Related Questions

i am trying to highlight the following menu <ul class=listing> <li><a href=Review.html>Review</a></li> <li><a href=Preview.html>Preview</a></li>
I am trying to render HTML as it is typed. That is, a user
What i am trying to do is style a text retrieven from sql. But
I am trying to make a html editor that allows you to preview the
I'm trying to create asp mvc 3 page with a form with text fields
i'm trying the camera preview This is my code and it doesn't throw any
I am trying to get a camera preview with a color effect applied to
I'm trying to setup xVal with an ASP.NET MVC 2 Preview 1 project. I'm
I am trying to make the same user interface to preview image like on
I'm trying to modify the SurfaceView I use for doing a camera preview in

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.