[英]How can I find out what precisely is the conflict between 2 jquery scripts?
I am building a site on top of the Shopify platform and on one page a javascript conflict occurs. 我在Shopify平台上构建了一个网站,并且在一页上发生了JavaScript冲突。 I have no idea how I can find out what exactly causes the conflict - any info on how I can find this out would be greatly appreciated!
我不知道如何找出导致冲突的确切原因-我将不胜感激!
Here is the gist: 要点如下:
This is the page I am using as a test page. 这是我用作测试页的页面。 Unless I mute the scripts.js the click function on the filters of the isotope script does not do anything.
除非我将scripts.js静音,否则同位素脚本过滤器上的click函数不会执行任何操作。
This is from the html file in question: 这来自相关的html文件:
<!-- conflict!
<< path to 'scripts.js' >>
-->
<!-- Begin Isotope -->
<< path to 'jquery.isotope.min.js' >>
<script>
$(window).load(function(){
var $container = $('#isocontainer'),
$filterLinks = $('#isofilters a');
$container.isotope({
itemSelector: '.item',
filter: '*'
});
$filterLinks.click(function(){
var $this = $(this);
// don't proceed if already selected
if ( $this.hasClass('selected') ) {
return;
}
$filterLinks.filter('.selected').removeClass('selected');
$this.addClass('selected');
// get selector from data-filter attribute
selector = $this.data('filter');
$container.isotope({
filter: selector
});
});
});
</script>
<!-- End Isotope -->
I'd be happy with any hints on how I can find out what the concrete conflict is. 关于如何找出具体冲突的任何提示,我都会感到满意。 Let me know if I need to provide more/different information.
让我知道是否需要提供更多/不同的信息。
Thanks, Alex 谢谢,亚历克斯
Are you loading JQuery first? 您是先加载JQuery吗?
My guess is that there's an issue with using the $ operator in the Scripts.Js file. 我的猜测是在Scripts.Js文件中使用$运算符存在问题。 Is there a reason to use Jquery(window)....over $(window)?
是否有理由在$(window)上使用Jquery(window)....? Same with Jquery(document).ready(..over $(document).ready(....?
与Jquery(document).ready(.. over $ {document).ready(....?
You should be able to just use $ instead of JQuery. 您应该能够只使用$而不是JQuery。
I cant understand your question fully . 我不能完全理解你的问题。 I think your jquery script is conflicting with other library .If this is the problem check the below script
我认为您的jquery脚本与其他库冲突。如果这是问题,请检查以下脚本
var hack = $.noConflict();
Use hack instead of $ in every part of the script where you uses $ . 在使用$的脚本的每个部分中使用hack代替$。
Greetings 问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.