Forum: Ruby on Rails Remote form in popover processing as html

A66ac44d261ef0b217659efc3c88273c?d=identicon&s=25 "Thomas Dragsbæk" <tdragsbaek@gmail.com> (Guest)
on 2013-08-09 12:36
(Received via mailing list)
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>
Aa082c8b00a50928e5860dcd70bf2368?d=identicon&s=25 tamouse m. (tamouse_m)
on 2013-08-09 17:32
(Received via mailing list)
On Aug 8, 2013, at 11:54 AM, Thomas Dragsbk <tdragsbaek@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| %>
A66ac44d261ef0b217659efc3c88273c?d=identicon&s=25 "Thomas Dragsbæk" <tdragsbaek@gmail.com> (Guest)
on 2013-08-09 18:14
(Received via mailing list)
Niiiiiiice! that did it, thanks!
5f94b9b346c2aa648a80bc259978e5bc?d=identicon&s=25 Colin Law (Guest)
on 2013-08-09 22:49
(Received via mailing list)
On 9 August 2013 17:12, Thomas Dragsbk <tdragsbaek@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
A66ac44d261ef0b217659efc3c88273c?d=identicon&s=25 "Thomas Dragsbæk" <tdragsbaek@gmail.com> (Guest)
on 2013-08-25 11:54
(Received via mailing list)
you're right, thanks
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.