我的下拉菜单突然停止工作。我能想到的唯一变化就是运行rake assets:precompile
,现在网站上的JS很复杂。
以下是没有工作的下拉列表(呈现的HTML):
<header class="navbar navbar-fixed-top navbar-inverse">
<div class="logofont">
<nav>
<ul class="nav navbar-nav navbar-right">
<li id="blacklink" class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Login <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li id="blacklink"><a href="/login">For Drivers</a></li>
<li id="blacklink"><a href="/shoplogin">For Businesses</a></li>
<li class="divider"></li>
</ul>
我也遇到了create.js表单上的按钮问题,该表单通过jQuery创建了一个对象而没有重新加载,但现在每次创建两个。所有这些都没有改变我的代码。有人能让我知道我能看到什么吗?不知道如何解决这个问题。
这就是create.js
<% if @car.errors.present? %>
$('#error_messages').html("<%= escape_javascript(render 'shared/error_messages', object: @car) %>");
<% else %>
if($('#car_feed ul').length == 0){
$('#car_feed').html("<ul class=cars></ul>")
}
$('#car_feed ul').append("<%= escape_javascript(render 'cars/car', car: @car) %>");
<% end %>
表单
<%= form_for(@car, html: {multipart: true, remote: true}) do |f| %>
<h3> Add Your Car</h3>
<div class="field">
<%= f.text_area :year, placeholder: "Year i.e. '1993" %>
<%= f.text_area :brand, placeholder: "Brand i.e. 'Ford'"%>
<%= f.text_area :model, placeholder: "Model i.e. 'Mustang'" %>
<%= f.text_area :vin, placeholder: "17 digit VIN number" %>
<%= f.text_area :mileage, placeholder: "Current Car Mileage" %>
</div>
<p> Add a Photo </p>
<span class="picture">
<%= f.file_field :picture, accept: 'image/jpeg,image/gif,image/png' %>
</span>
<div id="error_messages">
</div>
<%= f.submit "Add Car", class: "btn btn-add btn-primary" %>
<button class="btn btn-hide btn-primary"> Hide Form </button>
<% end %>
<script type="text/javascript">
$('#car_picture').bind('change', function() {
size_in_megabytes = this.files[0].size/1024/1024;
if (size_in_megabytes > 5) {
alert('Maximum file size is 5MB. Please choose a smaller file.');
}
});
</script>