2012-01-19 29 views
1

我想知道是否有其他人遇到過問題,如Twipsy(來自Twitter引導程序)和Tablesorter等jQuery腳本在本地工作,但不在Heroku上工作。Heroku資產爲Twipsy和Tablesorter無法正常工作,本地是

每次我清理我的公共/資產文件夾併爲部署環境預編譯時。

的腳本實際上顯示了在在Heroku上預編譯的JS,但它似乎並沒有被認可....

怪異的一部分是,下拉菜單中的第一個jQuery的/ Ajax的功能工作正常上Heroku的。

我使用的Rails 3.1在Heroku上雪松堆棧

這裏是我的資產/ 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

回答

2

也有類似的問題。 在行之前放置引導程序代碼爲我解決了這個問題。

+0

感謝您的回答。我試過了,但沒有改變任何東西。當我在Safari中運行腳本控制檯時,出現以下錯誤:TypeError:'undefined'不是函數(計算'a(「#sortTable」)。tablesorter({headers:{5:{sorter:!1},8 :{分揀機:1},9:{分揀機:1}},sortlist中:[[0,0]]})')'。也許我的代碼有問題?也許預編譯搞亂了代碼? –

+1

也許是一個愚蠢的評論,但是,請確保在運行調用tableSorter/twipsy函數的代碼之前加載jquery.tablesorter.js文件(和Twipsy js文件)。 我只提到這一點,因爲我沒有看到你加載bootstrap/twipsy/tablesorter文件(除非你讓他們生活在/ assets/javascript中,並且他們用'// = require_tree .'加載。 此外確保你有這個config.assets.initialize_on_precompile = false'在config/application.rb中,我還必須在config/enviroments/production.rb中設置'config.assets.compile = true' – 8bithero

+0

確實所有的js都在我的資產文件中。我所做的就是強制調用所有bootstrap和tablesorter文件,按照你提到的那樣更改配置,然後在推送heroku服務器之前重新預編譯整個配置,它可以工作!非常感謝! –

相關問題