jquery - Form Different Submit Action -


i have form showing report, need 3 features print pdf, print excel, , showing preview via html using js

this first condition pdf , excel , work both.

controller:

respond_to |format|   if params[:print]     format.html { redirect_to :action => "report", :format => "pdf", :start_period => params[:start_period], :end_period => params[:end_period], :warehouse => params[:warehouse] }   elsif params[:excel]     format.html { redirect_to :action => "report", :format => "xls", :start_period => params[:start_period], :end_period => params[:end_period], :warehouse => params[:warehouse] }   else     format.html   end end 

view:

<%= form_tag(models_path, :method => "get") %>   <%= submit_tag "#{t 'pdf'}", :name => "print" %>   <%= submit_tag "#{t 'excel'}", :name => "excel" %> <% end %> 

but when start adding preview feature through js, not error, both submit button (pdf n excel) pointing js.

new controller

respond_to |format|   if params[:print]     format.html { redirect_to :action => "report", :format => "pdf", :start_period => params[:start_period], :end_period => params[:end_period], :warehouse => params[:warehouse] }   elsif params[:excel]     format.html { redirect_to :action => "report", :format => "xls", :start_period => params[:start_period], :end_period => params[:end_period], :warehouse => params[:warehouse] }   else     format.html     format.js # new line   end end 

new view

<%= form_tag(models_path, :method => "get", :id => "headers_search") %>   <%= submit_tag "#{t 'ep.submit'}", :name => nil, :remote => true %>   <%= submit_tag "#{t 'pdf'}", :name => "print" %>   <%= submit_tag "#{t 'excel'}", :name => "excel" %> <%= end %> 

headers_search pointing on application.js

$.fn.ajaxfilter = function() {   this.submit(function() {     $.get(this.action, $(this).serialize(), null, "script");   return false;   }); }  $("#headers_search").ajaxfilter(); 

so, confuse on did mistake.. i'm kind of rails newbie. thanks

try with

if params[:name] == "print" 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -