在集合上选择一个表单 - Rails

时间:2015-03-06 12:06:14

标签: ruby-on-rails ruby

我正在尝试创建一个在集合选择选项上提交的表单,比如当我从下拉列表中选择一个值时,它应该发布,下面发布的内容不起作用,

<%= form_tag edit_zone_management_path, :method => 'get', :id => "bar" do %>
  <%= collection_select :dropdown, :id, Server.where(:id => @arr),:id, :server_name, :prompt => true, :selected => @sid %>
  <%end%>

有人可以指出这里缺少什么吗?

加成

有一些coffeescript与此集合选择绑定。

$ ->
$("#dropdown_id").live "change", -> // id of the collection_select

 index = this.selectedIndex


 uid = window.location.pathname.split("/")
 if index == 0
    index += 1
 response = "{ \"key\": { \"value\" : #{index} } }"
 #window.location.replace(uid[0]+ "/" + uid[1] + "/" + uid[2] + "/" + uid[3] + "/" +uid[4])

 $.ajax({
        type: 'POST',
        url: '/configuration/zone_management/updategrid/',
        data: response,
        contentType: "application/json",

 });

1 个答案:

答案 0 :(得分:0)

您似乎错过了$.ajax电话的任何处理程序,请尝试添加一些:

$.ajax({
  type: 'POST'
  url: '/configuration/zone_management/updategrid/'
  data: response
  contentType: "application/json"
  success: (response) ->
    console.log response
    alert "Success fired"
  error: (response) ->
    console.log response
    alert "Error fired"
 })

这只是示例,因此请相应调整处理程序!

祝你好运!