I looking for the solution to use two submit buttons with one form like the following:
- The first should submit the given form, to the create function in my controller
- The second should execute the given form remotely, to show the entered text under the form as preview
View:
<%= form_for @topic do |f| %>
.................
... some code ...
.................
<p>
<%= f.fields_for :topic_content do |tf| %>
<%= tf.text_area :text , :id => 'topic_text', :cols => 100 , :rows => 15, :class => 'topic_text' %></p>
<% end %>
.................
... some code ...
.................
<%= f.submit "Save", :name => 'save' %>
<%= f.submit "Preview", :name => 'preview' %>
<%end%>
<div id='preview_topic_text'>
</div>