這是一個非常基本的引導電網:引導不維持電網
<div class="row">
<div class="col-md-12">
</div>
</div>
<div class="row">
<div class="col-md-4" id="home_form">
<%= render "supporters/form" %>
</div>
<div class="col-md-8" id="home_list" id="home_list">
<%= render 'supporters/show_supporters' %>
</div>
</div>
但是我這有,這在以前直接放置像一個普通的渲染軌有錯誤形成上述表單格式錯誤。
$(build_error).insertBefore("#home_form");
但現在它把它的左邊,並用相同的高度#home_form,並引發#home_list兩下。
build_error:
<% if @supporter.save %>
$("#home_list").html("<%= j render 'show_supporters' %>")
$("home_form").html("<%= j render 'form' %>")
<% else %>
$("#home_form").html("<%= j render 'form', supporter: @supporter %>")
$('#build_error').remove();
<% if @supporter.errors.any? %>
var build_error = "<div class='alert alert-danger' id='build_error'>";
build_error += "You've got <%= pluralize(@supporter.errors.count, 'error') %>.";
build_error += "<ul id='error_explanation'>";
<% @supporter.errors.full_messages.each do |msg| %>
<% if msg === "Ip has already been taken" %>
<% msg = "You've already posted your support. Thanks!" %>
<% end %>
build_error += "<li><%= j msg %></li>";
<% end %>
build_error += "</ul>";
build_error += "</div>";
$(build_error).insertBefore("#home_form");
<% end %>
<% end %>
編輯:
<div class="row">
<div class="col-md-4">
<div id="home_form">
<%= render "supporters/form" %>
</div>
</div>
<div class="col-md-8" id="home_list" id="home_list">
<%= render 'supporters/show_supporters' %>
</div>
</div>
什麼是'build_error'? – Vucko
已更新。 ...我是一個n00b,只是扔東西我拿起 – daveasdf