简体   繁体   English

在Drupal 7中启用聚合时,Javascript停止工作

[英]Javascript stops working when aggregation is enabled in Drupal 7

Javascript stops working when aggregation is enabled in Drupal 7 while I am logged in and admin toolbar menu is visible. 当我登录后在Drupal 7中启用了聚合并且可见管理工具栏菜单时,Javascript停止工作。 When I am not logged in and admin menu is not visible everything works fine. 当我未登录且管理菜单不可见时,一切正常。 Also when aggregation is OFF and I am looged in and admin menu is visible everything works fine. 另外,当聚合处于关闭状态并且我被掠过并且管理菜单可见时,一切正常。

So when aggregation is ON and admin menu on, javascript of the site does not work. 因此,当启用聚合并且打开管理菜单时,该站点的javascript无法正常工作。

Any ideas ? 有任何想法吗 ?

Most likely one of your JS files has a syntax error like a trailing ',' at the end of an object definition or a missing ';'. 您的JS文件中很可能有一个语法错误,例如在对象定义的末尾加上“,”或缺少“;”。

For example: 例如:

var a = {
  a:1,
  b:2,
  c:3, // trailing ','
} // missing ';'

The reason it may only appear with the admin tool bar could be one of the following: 它可能仅与管理工具栏一起出现的原因可能是以下之一:

1) The order in which the files are aggregated causes the syntax error to be placed ahead of the code for the admin toolbar causing JS to error out before the toolbar has a chance to display. 1)聚集文件的顺序导致语法错误被放置在管理工具栏的代码之前,从而导致JS在工具栏有机会显示之前出错。 (Syntax errors cause many runtime JS compilers to stop processing the whole file, which in the case of aggregated files, can mean a large chunk of your JS never gets to run) (语法错误导致许多运行时JS编译器停止处理整个文件,对于聚合文件,这可能意味着您的JS绝大部分都无法运行)

2) The JS file the syntax error resides is ONLY added when the admin toolbar is present. 2)仅在存在管理工具栏时添加语法错误所在的JS文件。

The first place I would check is any custom JS files that you have created. 我首先要检查的是您创建的所有自定义JS文件。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM