-2
我正在尝试预览文本区域。但它dosnt工作。Rails帮助预览文本字段
我new.html.erb:
<h1>New post</h1>
<%= render 'form' %>
<%= link_to 'Back', posts_path %>
我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>
我new.js.erb:
$('#post-preview').html($('#post_body_html').val());
我试图创造一些这样的:http://sedition.com/a/2662 – 2011-05-28 18:15:07
您能不能告诉我怎么样在网站上做预览,我链接到 – 2011-05-28 19:13:43
@Rails初学者他只是向你展示了如何在JavaScript中编写预览功能,这正是你想要的。 – 2011-05-29 03:19:39