[英]Making a form on collection select - Rails
我正在嘗試創建一個在集合選擇選項上提交的表單,比如當我從下拉列表中選擇一個值時,它應該發布,下面發布的內容不起作用,
<%= 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",
});
看起來你錯過了$.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"
})
這只是示例,因此請相應調整處理程序!
祝好運!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.