我在让资产管道编译的 javascript 函数在生产中工作时遇到了一些麻烦。它在开发中运行良好。
Javascript
# app/assets/javascript/subscribe.js
$(function() {
$('#fat-btn').click(function() {
var btn = $(this)
btn.button('loading')
setTimeout(function () {
btn.button('reset')
}, 2000)
});
});
我的观点
# app/assets/subscribe.html.erb
<div class="subscribe">
<%= form_tag subscribe_path, class: "form-inline" do %>
<%= text_field_tag :email, nil, :type=>"email", :placeholder => 'Your email address' %>
<%= button_tag "Go", id: "fat-btn", class: "btn", data: { "loading-text" => "loading...", "toggle" => "button"} %>
<% end %>
</div>
我的应用程序 Javascript
# app/assets/javascript/application.js
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require_tree .
任何帮助都非常感谢。谢谢