有没有一种方法来提交AJAX / JSON请求与simple_form Rails的 [英] Is there a way to submit ajax/json requests with simple_form for Rails

查看:162
本文介绍了有没有一种方法来提交AJAX / JSON请求与simple_form Rails的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用的form_for,我能够通过,虽然选择和collection_select助手这样的Ajax请求的标准Rails的:

With the standard Rails form_for, I was able to pass ajax requests though select and collection_select helpers as such:

<%= address.collection_select :country, @countries, :id, :name, {:include_blank => false}, "data-remote" => true, "data-url" => "/ajax/states", "data-type" => :json  %>

我似乎无法弄清楚如何与做 simple_form

推荐答案

想通了。你只需要添加这样的:

Figured it out. You just need to add the this:

:input_html => {"data-remote" => true, "data-url" => "/yoururl", "data-type" => :json}

这篇关于有没有一种方法来提交AJAX / JSON请求与simple_form Rails的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆