简体   繁体   English

Javascript不在Heroku上运行,开发正常,其他很好

[英]Javascript not running on Heroku, dev fine, others fine

I have a Rails 3.1 app with several Javascripts that run just fine on Heroku. 我有一个带有几种Javascript的Rails 3.1应用程序,它们可以在Heroku上很好地运行。 I wanted to auto detect time zones and started working with this Jon Nylanders awesome script to do that. 我想自动检测时区,并开始使用这个Jon Nylanders出色的脚本来做到这一点。 It's available here: https://bitbucket.org/pellepim/jstimezonedetect/src 可以在这里找到: https : //bitbucket.org/pellepim/jstimezonedetect/src

Now the problem is, this Javascript runs just fine on my local machine but not on Heroku. 现在的问题是,此Javascript在我的本地计算机上运行得很好,但在Heroku上却没有。 The console in Safari says the function is undefined. Safari中的控制台说该功能未定义。 I call it like this: 我这样称呼它:

<script type="text/javascript">
  var tz = jstz.determine();
</script>

The main difference between this Javascript and the others I use is that this one has a name space. 此Javascript与我使用的其他Javascript之间的主要区别在于,该Javascript具有名称空间。 Maybe that has something to do with it? 也许与它有关?

I have run rake and I have verified that application.js contains the script. 我已经运行rake,并且已经验证了application.js包含脚本。 I have tried the downloadable minified version as well as the full source in it's own .js file. 我尝试了可下载的缩小版本以及其自己的.js文件中的完整源代码。

It turns out there was an error in another Javascript, an error that I disregarded for the time being (as I didn't use that code anyway). 事实证明,另一个Javascript中有一个错误,我暂时不理会这个错误(因为无论如何我都没有使用该代码)。 When compiled into application.js however, this error somehow disturbed the execution of all the other javascripts too. 但是,当编译为application.js时,此错误也会以某种方式干扰所有其他javascript的执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Rails:CSS / Javascript在本地运行良好,但在Heroku上却无法运行 - Rails : CSS/Javascript working fine locally but not on Heroku JavaScript setTimeout可以在某些对象类型上正常运行吗? - JavaScript setTimeout runs fine on some object types by not others? 正常运行之前的Javascript代码 - Javascript code running fine until put into a function Javascript Uncaught Type Error仅在实时环境中有效,在Dev上工作正常 - Javascript Uncaught Type Error on Live environment only, works fine on Dev Javascript部署到Heroku时未执行,但在本地运行良好 - Javascript not executing when deployed to heroku, but works fine locally javascript方法无法在IE中编译,但在运行调试时可以正常运行 - javascript method not compiling in IE but works fine when running debug 为什么 javascript 脚本没有在一个 wordpress 页面上运行,但在另一个页面上运行良好? - Why is a javascript script not running on one wordpress page, but working fine on another? 用JavaScript打印不能正常工作吗? - Printing in JavaScript is not working fine? NextJS fetch() 在运行下一个构建时抛出无效的 URL 错误,但下一个开发工作正常 - NextJS fetch() throws invalid URL error when running next build but next dev works fine 测试脚本很好,但不能实时运行 - Testing script is fine but running live is not
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM