I have this code in my view:
<%= form_for :folder_name, :remote => true, :method => "get", :url => {:action
=> "show_workflow_list"} do |f| %>
<%= f.select :foldernames, options_for_select(@folders, @folders.first), {}, {:onchange => ("this.form.submit()")}%><br /><br />
<%= hidden_field_tag 'selected_domain', params[:domain_selected] %>
When I change the value in the dropdown, the form is being submitted as:
Processing by DeploymentGroupController#show_workflow_list as HTML
Parameters: {"utf8"=>"Γ£ô", "folder_name"=>{"foldernames"=>"DETAIL_ADJUSTMENT"
When I add a submit button instead of a :onchange=> like below:
<%= form_for :folder_name, :remote => true, :method => "get", :url => {:action => "show_workflow_list"} do |f| %>
<%= f.select :foldernames, options_for_select(@folders, @folders.first)%><br /><br />
<%= hidden_field_tag 'selected_domain', params[:domain_selected] %>
<pre><%= f.submit "Submit"%></pre>
the request is being submitted like this:
Processing by DeploymentGroupController#show_workflow_list as JS
Parameters: {"utf8"=>"Γ£ô", "folder_name"=>{"foldernames"=>"DETAIL_ADJUSTMENT"
I have the following code in my show_workflow_list action:
def show_workflow_list
//some code
respond_to do |format|
format.js
end
end
and I have a show_workflow_list.js.erb file which has the following content:
$('#workflow_selection').html("<%=j render "show_workflow_list" %>");
The problem is when I change it to onchange=> submit, it is processing the action as HTML:
Processing by DeploymentGroupController#show_workflow_list as HTML
and not as JS when there is a submit button:
Processing by DeploymentGroupController#show_workflow_list as JS
so I'm getting back a 406 status error and the show_workflow_list is not being rendered.
Update:
I understood why onchange=> is being sent as HTML. The reason is that the format for select is "select(object, method, choices, options = {}, html_options = {})". The place i'm mentioning ":onchange=>this.for.submit" is under html_options={}" which is why it is being submitted as HTML.
I need to render a partial _show_workflow_list.html.erb between a <div> on the same page, so I changed the code in my controller like this:
def show_workflow_list
//code here
respond_to do |format|
format.html{?}
end
end
In the code above, I need to fill something in {} the format.html so that it will render the partial _show_workflow_list between the div tags in my make_deployment_group.html.erb.