简体   繁体   English

解决与Java的eval()函数的冲突

[英]Resolve conflict with eval() function of Javascript

I am trying to set up the Responsive Menu using combined.js a merged library of Jquery Sizzle and jQuery core, it is posted here: 我正在尝试使用combined.js设置响应菜单,该菜单是Jquery Sizzle和jQuery core的合并库,发布在这里:

https://pastee.org/erewc https://pastee.org/erewc

But it's eval function conflicts and produces error when I include it in a page having many scripts loaded already like jQuery(smartWizard) and PrototypeJS. 但是,当我将它包含在已经加载了许多脚本(如jQuery(smartWizard)和PrototypeJS)的页面中时,它的eval函数发生冲突并产生错误。

Error produced is as below: 产生的错误如下:

TypeError: $(...) is null
$('options_2_2').advaiceContainer = 'options-2-container';$('options_2_2').callb...

in combined.js > line 623 combined.js > line 623

It's involving eval function so I have no clue how to resolve it. 它涉及eval函数,所以我不知道如何解决它。 I don't think jQuery noConflict will work here, still suggestions are welcome. 我认为jQuery noConflict在这里不起作用,仍然欢迎提出建议。

I don't know if it's a temporary fix or permanent solution(time will tell), but I managed to resolve the conflict by putting a condition around the eval function call(in combined.js) like below: 我不知道这是临时解决方案还是永久解决方案(时间会证明一切),但我设法通过在eval函数调用(在combined.js中)周围放置条件来解决了冲突,如下所示:

if(t.indexOf("$('options_") == -1) {
  e.eval.call(e, t)
}

As I am sure none of my menu elements have "options_" in their class or id attribute. 我确信我的菜单元素的class或id属性都没有“ options_”。

So my conflict is resolved for now, but still feel free to post your answers if you have a better and cleaner approach for a permanent solution. 因此,我的冲突目前已解决,但如果您有更好,更清洁的永久解决方案,仍然可以随时发布您的答案。

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

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