rubyrookie
2013-Feb-03 23:25 UTC
Remote form is been submitted as html instead of javascript on second submit
I have a remote form that is being submitted as html intead of javascript on second attempt when clicking on update or create. The form gets submitted as javascript on first attempt. The form gets submitted as html on second attempt. On third attempt it gets submitted as javascript. I want it to get submitted as javascript always. Can anyone help me out her to figure it out? Here is my form <%= semantic_form_for @restaurant,:remote =>true do |f| %> <div class="errors"> </div> <%= f.inputs do %> <%= f.input :name,:input_html => { :autocomplete =>"off"}%> <%= f.input :street %> <%= f.input :city %> <%= f.input :state %> <%= f.input :zip %> <%= f.input :country %> <%= f.input :phoneNumber, :as => :phone %> <% end %> <%= f.actions do %> <%= f.action :submit, :as => :button %> <% end %> <% end %> Resturant Controller-> class RestaurantsController < ApplicationController # GET /restaurants # GET /restaurants.json def index @restaurants = Restaurant.all respond_to do |format| format.html # index.html.erb format.json { render json: @restaurants } end end # GET /restaurants/1 # GET /restaurants/1.json def show @restaurant = Restaurant.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @restaurant } end end # GET /restaurants/new # GET /restaurants/new.json def new @restaurant = Restaurant.new respond_to do |format| format.html # new.html.erb format.json { render json: @restaurant } end end # GET /restaurants/1/edit def edit @restaurant = Restaurant.find(params[:id]) respond_to do |format| format.html {} format.js {} end end # POST /restaurants # POST /restaurants.json def create @restaurant = Restaurant.new(params[:restaurant]) respond_to do |format| @restaurant.save format.html { render action: "new" } format.js {} end end # PUT /restaurants/1 # PUT /restaurants/1.json def update Rails.logger.fatal "In update" @restaurant = Restaurant.find(params[:id]) respond_to do |format| @restaurant.update_attributes(params[:restaurant]) format.html { render action: "edit" } format.js {} end end # DELETE /restaurants/1 # DELETE /restaurants/1.json def destroy @restaurant = Restaurant.find(params[:id]) @restaurant.destroy respond_to do |format| format.html { redirect_to restaurants_url } format.json { head :no_content } end end end -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/3kQ2dg-v8oIJ. For more options, visit https://groups.google.com/groups/opt_out.
tamouse mailing lists
2013-Feb-04 10:46 UTC
Re: Remote form is been submitted as html instead of javascript on second submit
On Sun, Feb 3, 2013 at 5:25 PM, rubyrookie <asajnani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have a remote form that is being submitted as html intead of javascript on > second attempt when clicking on update or create. The form gets submitted as > javascript on first attempt. The form gets submitted as html on second > attempt. On third attempt it gets submitted as javascript. I want it to get > submitted as javascript always. Can anyone help me out her to figure it out? > > Here is my form > > <%= semantic_form_for @restaurant,:remote =>true do |f| %> > <div class="errors"> > > </div> > <%= f.inputs do %> > <%= f.input :name,:input_html => { :autocomplete =>"off"}%> > <%= f.input :street %> > <%= f.input :city %> > <%= f.input :state %> > <%= f.input :zip %> > <%= f.input :country %> > <%= f.input :phoneNumber, :as => :phone %> > > <% end %> > > > <%= f.actions do %> > <%= f.action :submit, :as => :button %> > > <% end %> > <% end %>Maybe I''m not getting this, but isn''t :remote => true in semantic_form_for to be used when you''re doing AJAX? Your form is doing a straight HTTP POST it looks like to me... -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
rubyrookie
2013-Feb-05 00:24 UTC
Re: Remote form is been submitted as html instead of javascript on second submit
I thought default format is javascript. On Monday, February 4, 2013 2:46:03 AM UTC-8, tamouse wrote:> > On Sun, Feb 3, 2013 at 5:25 PM, rubyrookie <asaj...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org<javascript:>> > wrote: > > I have a remote form that is being submitted as html intead of > javascript on > > second attempt when clicking on update or create. The form gets > submitted as > > javascript on first attempt. The form gets submitted as html on second > > attempt. On third attempt it gets submitted as javascript. I want it to > get > > submitted as javascript always. Can anyone help me out her to figure it > out? > > > > Here is my form > > > > <%= semantic_form_for @restaurant,:remote =>true do |f| %> > > <div class="errors"> > > > > </div> > > <%= f.inputs do %> > > <%= f.input :name,:input_html => { :autocomplete =>"off"}%> > > <%= f.input :street %> > > <%= f.input :city %> > > <%= f.input :state %> > > <%= f.input :zip %> > > <%= f.input :country %> > > <%= f.input :phoneNumber, :as => :phone %> > > > > <% end %> > > > > > > <%= f.actions do %> > > <%= f.action :submit, :as => :button %> > > > > <% end %> > > <% end %> > > Maybe I''m not getting this, but isn''t :remote => true in > semantic_form_for to be used when you''re doing AJAX? Your form is > doing a straight HTTP POST it looks like to me... >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/ARsrLWUyEJQJ. For more options, visit https://groups.google.com/groups/opt_out.