0

GlobalPost 很高兴将 Isotope 用于我们的新业务页面。

http://www.globalpost.com/business-news

我们在 Drupal 上运行,因此每个页面上都运行着旧版本的 jquery。

我在页面上这样命名了新的 JQ

    <script type="text/javascript" src="/sites/all/themes/globalpost_3/js/jquery-1.7.1.min.js"></script>    
<script type='text/javascript'>
  // added to run both jquery releases on page and stop conflist with old JQ libraray
 var jQuery_1_7_1 = jQuery.noConflict(true);
</script> 
<script type="text/javascript" src="/sites/all/themes/globalpost_3/js/jquery.isotope.min.js"></script>
<script type="text/javascript" src="/sites/all/themes/globalpost_3/js/gp5_biz.js"></script>

最后像这样编辑了 isitope 的最小版本

....eturn this}})(window,jQuery_1_7_1);

如您所见,它可以正常加载并且运行良好,但是如果您调整窗口大小,则块不会重排。如果您选择了过滤器或排序,他们会这样做,但不会调整窗口大小。我看了很长时间您的代码,但似乎无法弄清楚可能导致问题的原因或如何解决它。

我必须为 jq 库命名空间以避免冲突,但在我这样做之前调整大小工作正常。我敢肯定,其他人将需要使用带有 Isotope 的名称间隔的 JQ。

谢谢你的帮助

4

2 回答 2

0

您在哪里(以及如何)初始化同位素?它可能与被引用的 jquery 有关。我是这样做的:

var jQuery171 = jQuery.noConflict(true);
jQuery171(function(){
    var $container = jQuery171("#container");
    $container.isotope({
        itemSelector: ".element"
    });
});
于 2012-05-03T20:46:40.557 回答
0

您最后的评论让我重新审视了我们如何包含新的 jquery 库以及真正的旧库。我开始认为旧的库可能是这里的坏人,因为它包含在主要的 js 文件(Drupal 系统)中,所以我不能直接访问它来给它一个特定的命名空间。遍历并重新命名所有本机 jq 函数也将是地狱。

我有一个想法,基本上让旧的 JQ 库基本上完成所有工作,它们的命名空间不碍事,就像这样。

<?php print $scripts; ?> <!-- all the JS for the site including old 1.3.2 JQuery -->

<script type="text/javascript">
  var jQuery132 = $.noConflict(true); // Kill the old JQ now that it is done with initializing old script
</script>

<script type="text/javascript" src="/sites/all/themes/globalpost_3/js/jquery-1.7.1.min.js"></script>    <!-- load shinny new JQuery which takes over $ and jQuery name space -->
<script type="text/javascript" src="/sites/all/themes/globalpost_3/js/jquery.isotope.min.js"></script>   <!-- non name spaced libs using default $ -->
<script type="text/javascript" src="/sites/all/themes/globalpost_3/js/gp5_biz.js"></script>  

这是有史以来最好的方法吗,也许不是,但它有效。

非常感谢您花费宝贵的时间帮助我解决这个问题。我以你的方式发送良好的业力。

于 2012-05-07T14:02:37.733 回答