使用ajax重新加载模式时丢失css

使用ajax重新加载模式时丢失css,css,ruby-on-rails,ajax,forms,Css,Ruby On Rails,Ajax,Forms,我有一个模式表单,当它包含验证错误时将不会提交。如果提交失败,我将在表单中使用:remote=>true重新加载模式,并使用以下javascript: $('#modal-treating').html('<%= escape_javascript(render('treating_form')) %>'); modal_error是问题顶部的javascript文件 谢谢你治疗形式是局部的吗?第一次是如何呈现的?对于AJAX请求,我使用.load from Jquery,在我看来

我有一个模式表单,当它包含验证错误时将不会提交。如果提交失败,我将在表单中使用:remote=>true重新加载模式,并使用以下javascript:

$('#modal-treating').html('<%= escape_javascript(render('treating_form')) %>');
modal_error是问题顶部的javascript文件


谢谢你

治疗形式是局部的吗?第一次是如何呈现的?对于AJAX请求,我使用.load from Jquery,在我看来,cleaner.load不会重新加载我的部分请求。是的,表格是一部分,我正在编辑我的问题,把它包括进去。谢谢不确定这是否是导致问题的原因,但顶部的html命令正在将id=modal-treating的div插入另一个id=modal-treating的div中。已将其删除,但仍然没有修复
<% if current_user %>
  <%= simple_form_for(@treating, :action => 'new', :remote => true)  do |f| %>

    <% if @treating.errors.any? %>

      <div id="modal-treating">
        <div class="modal-header">
          <h3><%= @user.first_name + " " + @user.last_name[0] + "." %></h3>
          <p>
            <% if @user.picture_url %>
              <%= image_tag(@user.picture_url, :size => "30x30") %>
            <% else %>
              <%= image_tag('smiley_small.png', :size => "30x30") %>
            <% end %> 
            <%= @user.headline %>
          </p>
        </div>

        <div class="modal-body">
          <div class="row-fluid">
            <form action="#" class="span12">
              <label for="treating-message"><h5>Introduce yourself to <%= @user.first_name %> (sample introductions):</h5></label>

              <%= f.hidden_field :requestee_id %>

              <div class="control-group">
                <%= f.label :intro, "Introduce yourself to " + @user.first_name + ":" %>
                <%= f.input :intro, :input_html => { :id => "treating-message", :class => "span12" } %>
              </div>

              <label for="treating-date-time">When?</label>
              <div class="control-group">
                <%= f.simple_fields_for :t_date_times_attributes do |t_date_time| %>
                  <%= t_date_time.simple_fields_for :"0" do |zero| %>
                    <%= zero.input :date, :input_html => { :class => "input-small datepicker" } %>
                    <%= zero.input :time, :input_html => { :class => "timepicker input-small" } %>
                  <% end %>
                <% end %>
              </div>

              <%= f.simple_fields_for :proposed_venues_attributes do |venue| %>
                <%= venue.simple_fields_for :"0" do |zero| %>
                  <%= zero.input :foursquare_id, :input_html => { :class => 'bigdrop', :id => 'e7' } %>
                <% end %>
              <% end %>

            </form>
          </div>
        </div>

        <div class="modal-footer">
            <div class="field">
            <a href="#" class="btn btn-link" data-dismiss="modal">Close</a>
            <%= f.submit "Send", id: "send-button" %>
            </div>
        </div>

      </div>

    <% else %>

      <div id="modal-treating" class="modal hide fade">
      <div class="modal-header">
        <h3><%= @user.first_name + " " + @user.last_name[0] + "." %></h3>
        <p>
          <% if @user.picture_url %>
            <%= image_tag(@user.picture_url, :size => "30x30") %>
          <% else %>
            <%= image_tag('smiley_small.png', :size => "30x30") %>
          <% end %> 
          <%= @user.headline %>
        </p>
      </div>

      <div class="modal-body">
        <div class="row-fluid">
          <form action="#" class="span12">
            <label for="treating-message"><h5>Introduce yourself to <%= @user.first_name %> (sample introductions):</h5></label>

            <%= f.hidden_field :requestee_id %>

            <div class="control-group">
              <%= f.label :intro, "Introduce yourself to " + @user.first_name + ":" %>
              <%= f.input :intro, :input_html => { :id => "treating-message", :class => "span12" } %>
            </div>

            <label for="treating-date-time">When?</label>

              <div class="control-group">
                <%= f.simple_fields_for :t_date_times_attributes do |t_date_time| %>
                  <%= t_date_time.simple_fields_for :"0" do |zero| %>
                    <%= zero.input :date, :input_html => { :class => "input-small datepicker" } %>
                    <%= zero.input :time %>
                  <% end %>
                <% end %>
              </div>


            <%= f.simple_fields_for :proposed_venues_attributes do |venue| %>
              <%= venue.simple_fields_for :"0" do |zero| %>
                <%= zero.input :foursquare_id, :input_html => { :class => 'bigdrop', :id => 'e7' } %>
              <% end %>
            <% end %>

          </form>
        </div>
      </div>

      <div class="modal-footer">
          <div class="field">
          <a href="#" class="btn btn-link" data-dismiss="modal">Close</a>
          <%= f.submit "Send", id: "send-button" %>
          </div>
      </div>

    </div>

    <% end %>
  <% end %>
<% end %>
def create

    @treating = current_user.sent_treatings.build(params[:treating])
    @user = @treating.requestee

    if params[:treating][:proposed_venues_attributes][:"0"][:foursquare_id] != ""
      build_proposed_venue_by_id(@treating,params[:treating][:proposed_venues_attributes][:"0"][:foursquare_id])
    end

    respond_to do |format|
      if @treating.save
        format.js { render :js => "window.location.replace('#{url_for(:controller => :treatings, :action => :index)}');" }
      else 
        format.html { render :action => "new" }
        format.xml  { render :xml => @treating.errors, :status => :unprocessable_entity }
        format.js { render 'modal_error' }
      end
    end

  end