remote-forms

After submitting a remote form with Rails, how do I redirect the user to another page?

北慕城南 提交于 2020-01-12 09:23:50
问题 I’m using Rails 4.2.3. I want to submit a form in a modal dialog, so I have set up my form like so <%= form_for @my_object, :remote => true do |f| %> but if the user submits the form successfully, I would like to reload the page that invoked the modal dialog with a notice of “Saved Successfully.” I can’t figure out what I need to put in my “format.js” to make this happen. This is what I have in my controller so far … def create @my_object = MyObject.new(my_object_params) @current_user = User

After submitting a remote form with Rails, how do I redirect the user to another page?

这一生的挚爱 提交于 2020-01-12 09:23:43
问题 I’m using Rails 4.2.3. I want to submit a form in a modal dialog, so I have set up my form like so <%= form_for @my_object, :remote => true do |f| %> but if the user submits the form successfully, I would like to reload the page that invoked the modal dialog with a notice of “Saved Successfully.” I can’t figure out what I need to put in my “format.js” to make this happen. This is what I have in my controller so far … def create @my_object = MyObject.new(my_object_params) @current_user = User

After submitting a remote form with Rails, how do I redirect the user to another page?

我与影子孤独终老i 提交于 2020-01-12 09:21:45
问题 I’m using Rails 4.2.3. I want to submit a form in a modal dialog, so I have set up my form like so <%= form_for @my_object, :remote => true do |f| %> but if the user submits the form successfully, I would like to reload the page that invoked the modal dialog with a notice of “Saved Successfully.” I can’t figure out what I need to put in my “format.js” to make this happen. This is what I have in my controller so far … def create @my_object = MyObject.new(my_object_params) @current_user = User

Rails turbolinks break submit remote form

流过昼夜 提交于 2019-12-19 04:09:14
问题 I'm having a rather weird problem using Rails 4, Turbolinks and a remote form. I have a form looking like: <%= form_for [object], remote: true do |f| %> <td><%= f.text_field :name, class: 'form-control' %></td> <td><%= f.email_field :email, class: 'form-control' %></td> <td><%= f.submit button_name, class: 'btn btn-sm btn-primary' %></td> <% end %> This form adds (creates) a new object. It does however not always work: When I load the page directly using the URL or a refresh; it works When I

Rails Remote Form does not post form parameters

↘锁芯ラ 提交于 2019-12-12 04:07:39
问题 my question involves the following partial view with a remote form: <% remote_form_for :phone_number, :url => {:controller => "edit", :action => "add_phone_number" }, :update => "phone_number_div" do |form| %> <%= form.text_field :number%> <%= form.select :type, PhoneNumber::PHONE_TYPE%> <%= submit_tag "Add" %> <% end %> When the Add button is pressed, the add_phone_number action is posted to, but the form values are not in the params variable. Does anyone know why this could be? 回答1: Most

Rails 3 Ajax Form Not Sending Params

断了今生、忘了曾经 提交于 2019-12-11 02:53:51
问题 I have a form on my index page that I'm using to sort records, I wanted to add some Ajax functionality to it but for some reason it's not sending my form parameters as soon as I added Ajax to the mix. Here's my form: <div id="sort-options"> <%= form_tag uploads_path, :method => "get", :remote => true do %> <%= select_tag "sort", options_for_select([["Creation Date", "created_at"], ["File Name", "name"], ["Rating", "rating_average"], ["Downloads", "downloads"]]) %> <%= select_tag "direction",

Rails: submit (via AJAX) when drop-down option clicked

孤街醉人 提交于 2019-12-09 04:20:34
问题 What is the easiest and most graceful way to auto-submit an AJAX form when a drop-down box's option is selected? I'm creating an administration page where the admin can modify user permissions (where "permissions" is stored as an integer), and I would like the "permissions" field to be a drop-down box that automatically submits and updates when the administrator clicks on the option he wants the user to have. Here's the stripped-down version of what I'm currently looking at. I need to know

After submitting a remote form with Rails, how do I redirect the user to another page?

亡梦爱人 提交于 2019-12-03 16:17:48
I’m using Rails 4.2.3. I want to submit a form in a modal dialog, so I have set up my form like so <%= form_for @my_object, :remote => true do |f| %> but if the user submits the form successfully, I would like to reload the page that invoked the modal dialog with a notice of “Saved Successfully.” I can’t figure out what I need to put in my “format.js” to make this happen. This is what I have in my controller so far … def create @my_object = MyObject.new(my_object_params) @current_user = User.find(session["user_id"]) @my_object.user = @current_user respond_to do |format| if @my_object.save

Rails turbolinks break submit remote form

半城伤御伤魂 提交于 2019-11-30 23:25:14
I'm having a rather weird problem using Rails 4, Turbolinks and a remote form. I have a form looking like: <%= form_for [object], remote: true do |f| %> <td><%= f.text_field :name, class: 'form-control' %></td> <td><%= f.email_field :email, class: 'form-control' %></td> <td><%= f.submit button_name, class: 'btn btn-sm btn-primary' %></td> <% end %> This form adds (creates) a new object. It does however not always work: When I load the page directly using the URL or a refresh; it works When I navigate from my app to this page; it fails When disabling Turbolinks for this link, the page worked