Remote form in popover processing as html

112 views
Skip to first unread message

Thomas Dragsbæk

unread,
Aug 8, 2013, 12:54:56 PM8/8/13
to rubyonra...@googlegroups.com
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>

Tamara Temple

unread,
Aug 9, 2013, 11:31:30 AM8/9/13
to rubyonra...@googlegroups.com

On Aug 8, 2013, at 11:54 AM, Thomas Dragsbæk <tdrag...@gmail.com> 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| %>
> --
> 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-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@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.
>
>

Thomas Dragsbæk

unread,
Aug 9, 2013, 12:12:46 PM8/9/13
to rubyonra...@googlegroups.com
Niiiiiiice! that did it, thanks!

Colin Law

unread,
Aug 9, 2013, 4:47:31 PM8/9/13
to rubyonra...@googlegroups.com
On 9 August 2013 17:12, Thomas Dragsbæk <tdrag...@gmail.com> 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

Thomas Dragsbæk

unread,
Aug 25, 2013, 5:52:52 AM8/25/13
to rubyonra...@googlegroups.com, cla...@googlemail.com
you're right, thanks
Reply all
Reply to author
Forward
0 new messages