Im trying to submit a rails remote form in a bootstrap popover, but it
keeps processing as html. There are no js errors, controller responds to js
and i have a create.js.erb. Can someone please point me to the problem?

Below is the content of my popover. Users have to options when submitting a
form - in order to make it faster for the user, i made two forms so the
user can choose an option and submit by clicking only one button.

POPOVER CONTENT:
<div id="booking_dialog">
   <div id="calendar_form" class="booking_dialog_content">

     <%= form_for @event || Event.new(:owner_id => current_block.actor_id,
:interval => 1, :title => 'option1', :room_id =>
current_block.loundry.room_id), :remote => true do |f| %>
       <% if f.object.errors.any? %>
         <div id="error_explanation">
           <h2><%= pluralize(f.object.errors.count, "error") %> evitaron que
se guardara esta actividad:</h2>
           <ul>
           <% f.object.errors.full_messages.each do |msg| %>
             <li><%= msg %></li>
           <% end %>
           </ul>
         </div>
       <% end %>

       <%= f.hidden_field :owner_id %>
       <%= f.hidden_field :start_at %>
       <%= f.hidden_field :end_at %>
       <%= f.hidden_field :all_day %>
       <%= f.hidden_field :room_id %>
       <%= f.hidden_field :title %>
       <%= f.hidden_field :description %>
       <%= f.hidden_field :frequency %>
       <%= f.submit 'Option1', id: option1_icon_link'%>
     <% end %>

     <%= form_for @event || Event.new(:owner_id => current_block.actor_id,
:interval => 1, :title => 'option2', :room_id =>
current_block.loundry.room_id), :remote => true do |f| %>

       <% if f.object.errors.any? %>
         <div id="error_explanation">
           <h2><%= pluralize(f.object.errors.count, "error") %> evitaron que
se guardara esta actividad:</h2>
           <ul>
           <% f.object.errors.full_messages.each do |msg| %>
             <li><%= msg %></li>
           <% end %>
           </ul>
         </div>
       <% end %>

       <%= f.hidden_field :owner_id %>
       <%= f.hidden_field :start_at %>
       <%= f.hidden_field :end_at %>
       <%= f.hidden_field :all_day %>
       <%= f.hidden_field :room_id %>
       <%= f.hidden_field :title %>
       <%= f.hidden_field :description %>
       <%= f.hidden_field :frequency %>
       <%= f.submit 'Option2', id: 'option2_icon_link'%>
     <% end %>

   </div>

</div>

--
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@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1ad9196a-92bf-471b-8e16-3c524f8d4509%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Tamara Temple at Aug 9, 2013 at 3:31 pm

    On Aug 8, 2013, at 11:54 AM, Thomas Dragsbæk wrote:

    Im trying to submit a rails remote form in a bootstrap popover, but it keeps processing as html. There are no js errors, controller responds to js and i have a create.js.erb. Can someone please point me to the problem?

    Below is the content of my popover. Users have to options when submitting a form - in order to make it faster for the user, i made two forms so the user can choose an option and submit by clicking only one button.

    POPOVER CONTENT:
    <div id="booking_dialog">
    <div id="calendar_form" class="booking_dialog_content">

    <%= form_for @event || Event.new(:owner_id => current_block.actor_id, :interval => 1, :title => 'option1', :room_id => current_block.loundry.room_id), :remote => true do |f| %>

    I'm going out on a limb here, but I think it's doing something with the precedence of || in your first bit. Try wrapping the @event || Event.new in parens and see what happens?

    <%= form_for (@event || Event.new(:owner_id => current_block.actor_id, :interval => 1, :title => 'option1', :room_id => current_block.loundry.room_id)), :remote => true do |f| %>
    <% if f.object.errors.any? %>
    <div id="error_explanation">
    <h2><%= pluralize(f.object.errors.count, "error") %> evitaron que se guardara esta actividad:</h2>
    <ul>
    <% f.object.errors.full_messages.each do |msg| %>
    <li><%= msg %></li>
    <% end %>
    </ul>
    </div>
    <% end %>

    <%= f.hidden_field :owner_id %>
    <%= f.hidden_field :start_at %>
    <%= f.hidden_field :end_at %>
    <%= f.hidden_field :all_day %>
    <%= f.hidden_field :room_id %>
    <%= f.hidden_field :title %>
    <%= f.hidden_field :description %>
    <%= f.hidden_field :frequency %>
    <%= f.submit 'Option1', id: option1_icon_link'%>
    <% end %>

    <%= form_for @event || Event.new(:owner_id => current_block.actor_id, :interval => 1, :title => 'option2', :room_id => current_block.loundry.room_id), :remote => true do |f| %>

    <% if f.object.errors.any? %>
    <div id="error_explanation">
    <h2><%= pluralize(f.object.errors.count, "error") %> evitaron que se guardara esta actividad:</h2>
    <ul>
    <% f.object.errors.full_messages.each do |msg| %>
    <li><%= msg %></li>
    <% end %>
    </ul>
    </div>
    <% end %>

    <%= f.hidden_field :owner_id %>
    <%= f.hidden_field :start_at %>
    <%= f.hidden_field :end_at %>
    <%= f.hidden_field :all_day %>
    <%= f.hidden_field :room_id %>
    <%= f.hidden_field :title %>
    <%= f.hidden_field :description %>
    <%= f.hidden_field :frequency %>
    <%= f.submit 'Option2', id: 'option2_icon_link'%>
    <% end %>

    </div>

    </div>

    --
    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@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1ad9196a-92bf-471b-8e16-3c524f8d4509%40googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0C6F33D2-F3C7-4D1B-B630-56C2DEFDB190%40gmail.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Thomas Dragsbæk at Aug 9, 2013 at 4:12 pm
    Niiiiiiice! that did it, thanks!

    --
    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@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/68167d82-93a2-48d1-ae77-12185279458b%40googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Colin Law at Aug 9, 2013 at 8:48 pm

    On 9 August 2013 17:12, Thomas Dragsbæk wrote:
    Niiiiiiice! that did it, thanks!
    I think it might be even nicer to setup @event in the controller. It
    is generally better to keep such code out of the view.

    Colin

    --
    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@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLu%2BYaAHG8OzWggOqB08%2Bs5SVmEUqH7JaLonjsToszj0bA%40mail.gmail.com?hl=en-US.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Thomas Dragsbæk at Aug 25, 2013 at 9:52 am
    you're right, thanks

    --
    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@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8ad36b3f-4abc-4682-a023-344fb27f0ef7%40googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedAug 9, '13 at 10:35a
activeAug 25, '13 at 9:52a
posts5
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase