Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9263171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T13:31:18+00:00 2026-06-18T13:31:18+00:00

im trying to use ajax forms witin a modal window to allow my users

  • 0

im trying to use ajax forms witin a modal window to allow my users to edit/create new objects, the issues im having is that the errors arent being displayed.

in my controller i have the following

 def create
    @user = User.find(current_user)
    @players = User.where(:team_id => current_user[:team_id]).all
    #params[:event][:datetime] = "#{params[:event][:date]} #{params[:event][:time]}"
    @event = Event.new(params[:event])
    respond_to do |format|
      if @event.save
        #Notifier.event_added(@event,@user).deliver
        format.html { redirect_to(events_url,
                                  :notice => "#{event_display_c(@event.event)} vs #{@event.opponent.name} was successfully created.") }
        format.js { @events = Event.all }
      else
        format.html { render :action => "new" }
        format.js { render :json => @event.errors, :status => :unprocessable_entity }
      end
    end
  end

in my create.js.erb i have

$(“#events_list”).replaceWith(“<%= escape_javascript render(‘events_list’) %>”);

and in my partial i have

 - if @event.errors.any?
  .alert-box.error
    %a.close{:href => ''} ×
    %strong Error:
    = pluralize(@event.errors.count, 'error')
    prohibited event from being saved:
    %ul
      - @event.errors.full_messages.each do |msg|
        %li= msg
%h5 Schedule Form
= form_for(@event, :html => { :class => "custom"}, :remote => true, :validate => true) do |f|
  .row
    .two.columns
      = f.label :event_type, :class =>'control-label'
    .four.columns
      = f.select :event, Event::EVENT_TYPES
    -if current_user.admin?
      .two.columns
        = f.label :team, :class =>'control-label'
      .four.columns
        = select("event", "team_id", Team.all.collect { |p| [truncate(p.name, :length => 18, :omission => '...'), p.id] }, {:prompt => 'Select a team'})
    - else
      =f.hidden_field :team_id, :value => current_user.team_id
  .row
    .two.columns
      = f.label :name, :class =>'control-label'
    .ten.columns
      = f.text_field :result_id, :class => "required"
  .row
    .two.columns
      = f.label :date_and_time, :class =>'control-label'
    .ten.columns
      .input-prepend
        %span.add-on
          %i.icon-schedule
      = f.text_field :time, :id => 'datepicker', :class => "hasDatepicker", "data-date-format" => "dd/mm/yyyy"
  .row
    .two.columns
      = f.label :duration, :class =>'control-label'
    .four.columns
      = f.number_field :duration, :placeholder => 'Time in Minutes'
    .two.columns
      = f.label :arrival_time, :class =>'control-label'
    .four.columns
      = f.number_field :arrival_time, :placeholder => 'Time in Minutes'
  .row
    .two.columns
      = f.label :location, :class =>'control-label'
    .four.columns
      = select("event", "location_id", Location.all.collect { |p| [p.name, p.id] }, {:include_blank => 'None'})
    .two.columns
      = f.label :opponent, :class =>'control-label'
    .four.columns
      = select("event", "opponent_id", Opponent.all.collect { |p| [p.name, p.id] }, {:include_blank => 'None'})
  .row
    .two.columns
      = f.label :players, :class =>'control-label'
    .four.columns
      = select(:event, :selected_players, @players.map { |p| [full_name(p), p.id] }, {:include_blank => false}, "data-placeholder" => 'Add Players to Lineup', :prompt => 'Add Players to Lineup', :multiple => "multiple", "data-customforms"=>"disabled")
    .two.columns
      = f.label :home_or_away, :class =>'control-label'
    .four.columns
      = f.select :home_or_away, Event::HOME_OR_AWAY, {:include_blank => 'None'}
  .row
    .two.columns
      = f.label :scores, :class =>'control-label'
    .three.columns
      = f.number_field :score_for, :placeholder => 'Our Score'
    .two.columns
      %label vs.
    .three.columns
      = f.number_field :score_against, :placeholder => 'Opponents Score'
  .row
    = f.submit :class => 'button success', :disable_with => "Saving Event..."
    = link_to 'Cancel', 'javascript:void(0);', :class => 'button alert close-reveal-modal'

what the console is outputting

   Started POST "/events" for 168.186.239.50 at 2013-02-08 06:59:47 +0100
Processing by EventsController#create as JS
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"CBiKEQN+Q2Dkhgt7MSJbjU7WzuUPgW0/z6m71KdDpnU=", "event"=>{"event"=>"1", "team_id"=>"", "time"=>"", "duration"=>"", "arrival_time"=>"", "location_id"=>"", "opponent_id"=>"", "selected_players"=>[""], "home_or_away"=>"", "score_for"=>"", "score_against"=>""}, "commit"=>"Create Event"}
  User Load (1.4ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 38 LIMIT 1
  User Load (1.1ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 38]]
  User Load (1.4ms)  SELECT "users".* FROM "users" WHERE "users"."team_id" = 1
   (0.4ms)  BEGIN
   (0.6ms)  ROLLBACK
  Event Load (0.9ms)  SELECT "events".* FROM "events" 
  Rendered events/_events_list.html.haml (1.1ms)
  Rendered events/create.js.erb (3.7ms)
Completed 200 OK in 516ms (Views: 13.3ms | ActiveRecord: 17.5ms)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T13:31:19+00:00Added an answer on June 18, 2026 at 1:31 pm

    Change the respond_to block to

    respond_to do |format|
      if @event.save
        #Notifier.event_added(@event,@user).deliver
        format.html { redirect_to(events_url,
                                  :notice => "#{event_display_c(@event.event)} vs #{@event.opponent.name} was successfully created.") }
        format.js { @events = Event.all }
      else
        format.html { render :action => "new" }
        format.js
      end
    end
    

    and change create.js.erb to

    `$("#events_list").html("<%= escape_javascript render('events_list') %>")`
    

    since you don’t have the #events_list div on that partial

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use AJAX for a web app game that im making.
I am currently trying to use AJAX in my application via jRails. I am
I am trying to use .ajax() to post a People object to a MVC2
I'm trying to use jquery.Ajax to post data to an ASP.NET MVC2 action method
I am using HMVC codeigniter. I am trying to use jquery ajax first time.
I am trying to use periodic refresh(ajax)/polling on my site by XMLHttp(XHR) to check
What I'm trying to do is to use ajax to get time from another
I'm trying to learn how to use AJAX in my rails apps so i've
I am trying to use the Bing Maps Ajax Control to plot pins of
I am trying to create a car make/model form using Javascript or AJAX, problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.