Is there a way to submit ajax/json requests with simple_form for Rails

后端 未结 5 1989
感情败类
感情败类 2021-01-05 09:43

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

<%= address.collection_select :cou         


        
5条回答
  •  猫巷女王i
    2021-01-05 10:39

    It seems the valid way to do this now is:

    :remote => true, :html => { :data => { :url => '/yoururl', :type => :json } }
    

    which may look a little better with ruby 1.9 hash syntax as:

    remote: true, html: { data: { url: '/yoururl', type: :json } }
    

    https://github.com/plataformatec/simple_form/wiki/HTML5-Attributes

提交回复
热议问题