1

我对 BOOTSTRAP 和 RAILS 3.2 有疑问,我无法显示我的表单。

index.html.erb

<%= link_to 'New Country', new_backend_country_path, class:"btn btn-primary", :id => 'create_country' %>

应用程序.js

//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require backend/bootstrap-modal.js
//= require rails.validations

    $('#create_country').click(function(e) {
        e.preventDefault();
        var href = $(e.target).attr('href');
        if (href.indexOf('#') == 0) {
            $(href).modal('open');
        } else {
            $.get(href, function(data) {
                $('<div class="modal fade" >' + data  + '</div>').modal();
            });
        }
    });

新的.html.erb

<div class="modal hide fade" id="modal-window">
  <div class="modal-header">
    <a href="#" class="close">×</a>
    <h6>Loading...</h6>
  </div>

  <div class="modal-body center">
    <%= render 'form' %>
  </div>

  <div class="modal-footer">&nbsp;
  </div>
</div>

_form.html.erb

<%= form_for([:backend, @country], :remote => true) do |f| %>

  <% if @country.errors.any? %>
            <% @country.errors.full_messages.each do |msg| %>
                <h4 class="alert_error"><%= msg %></h4>
            <% end %>
       <br>
  <% end %>

  <fieldset>
    <%= f.label :name %><br />
    <%= f.text_field :name, :class =>"upper" %>
  </fieldset>
  <fieldset>
    <%= f.label :code %><br />
    <%= f.text_field :code %>
  </fieldset>

    <footer>
        <div class="submit_link">
          <% if @country.new_record? %>
              <%= f.submit "Create", class:"alt_btn" %>
          <% else %>
              <%= f.submit "Update", class:"alt_btn" %>
          <% end %>
            <%= submit_tag "Cancel" %>
        </div>
    </footer>

<% end %>

我的表单没有显示并进入 MODAL DIALOG 它为我提供了带有菜单和页脚的整个页面。

谢谢您的帮助

4

0 回答 0