2012-01-19 7 views
1

Twipsy (Twitter 부트 스트랩) 및 Tablesorter와 같은 jQuery 스크립트가 로컬에서는 작동하지만 Heroku에서는 작동하지 않는 문제가있는 경우 궁금합니다.Twipsy 및 Tablesorter의 Heroku 자산이 로컬에서 작동하지 않습니다.

매번 public/assets 폴더를 정리하고 배포 환경에 맞게 사전 컴파일했습니다. 이상한 부분은 드롭 다운에 대한 첫 번째 jQuery를/아약스 기능이 잘에 작동되는 것을

스크립트는 실제로에게 Heroku에 미리 컴파일 된 JS에 표시하지만 인식하지 않는 것 같습니다 .... Heroku.

내가 Heroku가 삼나무 스택 여기

내 자산입니다에 레일 3.1 사용은/

// 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 . 

는 또한 자산 작동 만든 설정을 변경 application.js!

귀하의 도움을 받으실 수 있습니다.

aurelien

답변

2

비슷한 문제가있었습니다. //= require_tree . 줄 앞에 부트 스트랩 코드를두면이 문제가 해결됩니다.

+0

답변 해 주셔서 감사합니다. 나는 시도했지만 아무것도 변경하지 않았습니다. Safari에서 스크립트 콘솔을 실행할 때 다음과 같은 오류가 발생합니다. 'TypeError :'undefined '는'a ("# sortTable")을 평가하는 함수가 아닙니다. : {분류기 :! 1}, 9 : {분류기 :! 1}}, sortList : [[0,0]]}) ')'. 어쩌면 내 코드에 문제가있을 수 있습니까? 어쩌면 프리 컴파일이 코드를 엉망으로 만들고 있을까요? –

+1

글쎄 아마도 어리석은 주석이지만 tableSorter/twipsy 함수를 호출하는 코드를 실행하기 전에 jquery.tablesorter.js 파일 (및 Twipsy js 파일)을로드해야합니다. 부트 스트랩/twipsy/tablesorter 파일을로드하는 것을 보지 못했기 때문에 언급합니다 (자산/자바 스크립트에 살고 있지 않고'// = require_tree. '로로드 됨) 추가로 config/application.rb 파일에서'config.assets.initialize_on_precompile = false' 라인을 수정하십시오 config/enviroments/production.rb 파일에서도'config.assets.compile = true'를 설정해야만합니다 – 8bithero

+0

실제로 모든 js 파일이 내 자산 파일에 있습니다. . 내가 한 일은 모든 부트 스트랩 및 테이블 작성자 파일을 강제로 호출하는 것이 었습니다. 언급 한대로 구성을 변경하고 heroku 서버를 열기 전에 전체를 다시 컴파일하면됩니다. –

관련 문제