【发布时间】:2011-05-07 08:21:11
【问题描述】:
我正在尝试为我的文本区域创建预览:
我试过这个:
我的控制器:
def preview
post = Post.new(params[:post])
render :text => post.body_html
end
def new
@post = Post.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @post }
end
end
还有我的表格:
<%= 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="actions">
<%= f.submit %>
</div>
<% end %>
我应该如何在 body_html 文本区域的表单中进行预览? 我想在 body_html text_area 中输入内容时进行预览,它会立即预览。
【问题讨论】:
-
这只是关于 javascript
标签: javascript ruby-on-rails ruby ajax ruby-on-rails-3