Heroku assets for Twipsy and Tablesorter not working, locally yes

萝らか妹 提交于 2019-12-24 09:31:06

问题


I was wondering if anyone else ran into the problem where jQuery scripts such as Twipsy (from Twitter bootstrap) and Tablesorter work locally but not on Heroku.

Each time I cleaned my public/assets folder and precompiled for deployment environment.

The script actually shows up in the precompiled JS on heroku, but it doesn't seem to be recognized....

The weird part is that the first jQuery/Ajax function for the dropdown works fine on Heroku.

I use Rails 3.1 on heroku cedar stack

Here is my assets/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 .

Also changing the config assets made it work!

Your help would be most appreciated.

Aurelien


回答1:


Had a similar problem. Placing the bootstrap code before the line //= require_tree . solved this problem for me.



来源:https://stackoverflow.com/questions/8920836/heroku-assets-for-twipsy-and-tablesorter-not-working-locally-yes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!