-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