我想知道是否还有其他人遇到过问题,例如Twipsy(来自Twitter bootstrap)和Tablesorter等jQuery脚本在本地运行但在Heroku上运行。
每次我清理我的public / assets文件夹并为部署环境进行预编译。
该脚本实际上显示在heroku上的预编译JS中,但它似乎没有被识别....
奇怪的是,下拉列表的第一个jQuery / Ajax函数在Heroku上工作正常。
我在heroku雪松堆栈上使用Rails 3.1
这是我的资产/ application.js
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require jquery.tablesorter.min
//= require bootstrap-twipsy
//= require bootstrap-alerts
//= require bootstrap-dropdown
//= require bootstrap-modal
//= require bootstrap-popover
//= require bootstrap-scrollspy
//= require bootstrap-tabs
jQuery(function($) {
// when the #region_id field changes
$("#contact_country_id").live('change', function() {
// make a POST call and replace the content
var country = $('select#contact_country_id :selected').val();
if(country == "") country="0";
jQuery.get('/countries/update_city_select/' + country, function(data){
$("#cities").html(data);
})
return false;
});
});
jQuery(function($) {
$("#sortTable").tablesorter({
headers : {
5: {
sorter: false
},
8: {
sorter: false
},
9: {
sorter: false
}
},
sortList: [[0,0]]
});
});
jQuery(function($) {
$('.action-icon').twipsy();
$("a[rel=twipsy]").twipsy({
live: true
});
});
//= require_tree .
同时更改配置资产使其正常工作!
非常感谢您的帮助。
的Aurelien
答案 0 :(得分:2)
有类似的问题。
在行//= require_tree .
之前放置引导代码为我解决了这个问题。