0

Someone has used to the modal of twitterboostrap calling to _form.html.erb ?

This is my try.

first I add the next line in the form (this is other form)

<%= simple_form_for(@terreno, html: {class: "form-horizontal"}, remote: :true) do |f| %>
  <% if @terreno.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@terreno.errors.count, "error") %> prohibited this terreno from being saved:</h2>

      <ul>
      <% @terreno.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <%= f.input :titulo %>
  <%= f.input :direccion %>
  <%= f.input :region %>
  <%= f.input :metrocuadrado %>
  <%= f.input :precio %>
  <%= f.input :votos %>
  <%= link_to "Add image", new_image_path, id: "new_image", class: 'btn', remote: :true %>

  <div class="form-actions">
    <%= f.button :submit %>
  </div>
<% end %>

The next step has been create the view for image. in this Case the view is view/images/new.js.erb

In this file I add the next code:

$('#new_image').hide().after('<%= j render("form") %>')

When I clicked the button "Add image" no show the form, but when I show the console(firebug), this show me the content of the _form.html.erb (remember this form belongs to image controller).

Any idea ?

Pdt: My english is very bad, sorry.

4

1 回答 1

0

这可能归结为 HTML 转义字符。尝试:

$('#new_image').hide().after('<%= escape_javascript(raw render :partial => "form").html_safe %>');
于 2012-12-04T11:29:48.747 回答