javascript函数可通过javascript_include_tag获得,但不包括资产管道和application.js [英] javascript functions available via javascript_include_tag but not asset pipeline and application.js
问题描述
我很抱歉,如果这已经发布到别处,但我不确定如何甚至短语搜索这个问题。
基本上,我已经获得 fullcalendar.js
坐在 app / assets / javascripts /
中。在我的 application.js
文件中(当然在同一个文件夹中),我有以下内容...
// =需要jquery
// =需要jquery_ujs
// =需要基础
// = require_tree。
因此,如预期的那样 fullcalender.js
在资产编译过程中被清除,并最终在 application.js
中被提供给用户。
当我尝试引用 fullcalendar.js
中定义的函数时(因此在 application.js $ c $中定义) c>在编译资源之后),它会在firebug的js控制台中引发一个错误,指出
TypeError:$(...)。fullCalendar不是函数
,当然也是满日历不会呈现。
现在,如果我包含 挡住了,我查看了每个文件中的js并对它们进行比较,结果看不出有什么区别。资产管道是否有某些我不知道的东西,或者这是一个怪异的DOM问题?在这一点上,我只是不知道。 作为参考,这里是 让我感到困惑的是,从同一个文件中,一个直接链接到另一个文件,另一个流过资产管道流程。 任何见解或帮助都将非常感激。 将fullcalendar脚本放入 在tree.jquery和任何其他依赖的lib之前,需要在application.js中手动执行此脚本。 添加 检查加载的Javascript文件在头文件中,如果application.js是最后一个,则会出现依赖关系错误。在调用它之前,lib必须在那里。 My apologies if this has been posted somewhere else, but I'm not exactly sure how to even phrase a search for this problem. Basically, I've got So, as expected the The problem comes in when I try to reference a function defined in Now, however, if I include Baffled, I looked into the js in each file and compared them and can't see a difference. Is there something going on with the asset pipeline that I'm not aware of or is this some freaky DOM issue? I just have no idea at this point. For reference, here are the contents of both the What baffles me is that both the sources come from the same file, one is just linked to directly, the other flows through the asset pipeline process. Any insight or help would be GREATLY appreciated. Maybe a dependency error. I'll suggest you to use a better practice for such lib. Put the fullcalendar scripts into Require this script manually in application.js before the tree and after jquery and any other lib it depends. Add Check the loaded Javascript files in header, if application.js is the last, you have dependency error. The lib must be there before calling it. 这篇关于javascript函数可通过javascript_include_tag获得,但不包括资产管道和application.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!<%= javascript_include_tagfullcalendar.js%> $在所有其他脚本和样式表都被拉入之后,布局文件中的c $ c>按预期工作。
application.js
和 fullcalendar.js
,并链接到网站的网页来源。我只包括每个相关的完整日历部分,因为如果我包含所有内容,它对于要点或pastebin来说太大了。
application.js
- http://pastebin.com/byyNErB8
fullcalendar.js
- http://pastebin.com/k4p29YmP
vendor / assets / javascripts
/ = require'fullcalendar`
fullcalendar.js
sitting in app/assets/javascripts/
. Within my application.js
file (in the same folder of course) I've got the following...//= require jquery
//= require jquery_ujs
//= require foundation
//= require_tree .
fullcalender.js
gets swept up in the asset compiling process and ends up in the application.js
that is then served to the user.fullcalendar.js
(and thus defined in application.js
after compiling the assets) it throws an error stating TypeError: $(...).fullCalendar is not a function
in the js console of firebug, and of course full calendar doesn't render.<%= javascript_include_tag "fullcalendar.js" %>
in the layout file after all of the other scripts and stylesheets have been pulled in, it works as expected. application.js
and fullcalendar.js
that are linked to in the page source of the site. I've only included the relevant full calendar portion of each, as it's too large for gist or pastebin if I include everything.application.js
- http://pastebin.com/byyNErB8fullcalendar.js
- http://pastebin.com/k4p29YmP
vendor/assets/javascripts
/=require 'fullcalendar`