Hello i want to open new window on click of submit button using ruby on rails, Here is my code
<div class="actions">
<%= f.button :submit,:class => 'btn btn-md btn-success' do %>
<i class='fa fa fa-plus'></i> Create New Window
<% end %>
</div>
i have tried :target => "_blank" in submit, but it doesnt work, please help me
use formtarget="_blank".
<%= form_for @my_obj do |f|
<div class="actions">
<%= f.button :submit,:class => 'btn btn-md btn-success', :formtarget => "_blank" do %>
<i class='fa fa fa-plus'></i> Create New Window
<% end %>
</div>
This link will help you http://www.w3schools.com/tags/att_button_formtarget.asp
You have to pass target="_blank"
in your form
for an example
<form action="..." ...
onsubmit="window.open('google.html', '_blank', 'scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no');return true;">
Try this one
Did you try target sending target as _blank parameter in form_for not in submit button.
<%= form_for @my_obj, html: { target: "_blank" } do |f|
<div class="actions">
<%= f.button :submit,:class => 'btn btn-md btn-success' do %>
<i class='fa fa fa-plus'></i> Create New Window
<% end %>
</div>
If you want to open the window conditionally, depending upon successful submission of your form you might:
remote: true
on your formformat.js { render :show, status: :ok }
to your controllershow.js
file that runs window.open
per the reply by VishalThis is one way you can get started with AJAX forms
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With