【发布时间】:2013-02-13 01:42:00
【问题描述】:
所以我已经看到了具有相同标题的其他问题,并且我认为我没有遇到与他们相同的问题(特别是因为我没有使用 Drupal 并且文件似乎正在加载到页眉中如下所示)。我知道它找不到该功能,但我不知道为什么。这是 theme.liquid 头中的代码,用于设置 javascript 和样式:
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="canonical" href="{{ canonical_url }}" />
{% assign maxmeta = 155 %}
{% if template contains 'product' %}
<meta name="description" content="{{ product.description | strip_html | strip_newlines | truncate: maxmeta | escape }}" />
{% elsif template contains 'page' %}
<meta name="description" content="{{ page.content | strip_html | strip_newlines | truncate: maxmeta | escape }}" />
{% elsif template == 'index' and shop.description != '' %}
<meta name="description" content="{{ shop.description }}" />
{% endif %}
{{ 'skinCustom.css' | asset_url | stylesheet_tag }}
{{ 'jquery-1.4.2.min.js' | asset_url | script_tag }}
{{ 'jquery.jcarousel.min.js' | asset_url | script_tag }}
{% if template == 'index' %}
<title>{{ shop.name }}</title>
{% elsif template == '404' %}
<title>Page Not Found | {{ shop.name }}</title>
{% else %}
<title>{{ page_title }} | {{ shop.name }}</title>
{% endif %}
{% include 'fb-open-graph' %}
{% case settings.header_font %}
{% when "Rancho, cursive" %}
<link href='http://fonts.googleapis.com/css?family=Rancho' rel='stylesheet' type='text/css'>
{% when "'Amatic SC', cursive" %}
<link href='http://fonts.googleapis.com/css?family=Amatic+SC:700' rel='stylesheet' type='text/css'>
{% when "'Sancreek', cursive" %}
<link href='http://fonts.googleapis.com/css?family=Sancreek' rel='stylesheet' type='text/css'>
{% when "'Ubuntu Condensed', sans-serif" %}
<link href='http://fonts.googleapis.com/css?family=Ubuntu+Condensed' rel='stylesheet' type='text/css'>
{% endcase %}
{{ 'style.css' | asset_url | stylesheet_tag }}{% if template contains 'product' and settings.main_image_display == 'Lightbox' %}
{{ 'jquery.fancybox-1.3.4.css' | asset_url | stylesheet_tag }}{% endif %}
{{ 'modernizr.js' | asset_url | script_tag }}
{{ 'option_selection.js' | shopify_asset_url | script_tag }}
{% if template contains 'customers' %}
{{ "shopify_common.js" | shopify_asset_url | script_tag }}
{{ "customer_area.js" | shopify_asset_url | script_tag }}
{% endif %}
<script type="text/javascript">
$(document).ready(function() {
$('#mycarousel').jcarousel({ vertical: true, scroll: 1, start: 3 });
});
</script>
{{ '//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js' | script_tag }}
{{ content_for_header }}
当页面呈现时,我得到以下信息(我编辑了与这个问题无关的额外内容)。我把箭头指向了 jcarousel 所依赖的 js 和样式页面的引用。在尝试将其移至 Shopify 项目之前,我在一个单独的文件中提供了一个示例。
<head>
<meta charset="UTF-8">
--> <link href="http://cdn.shopify.com/s/files/1/0212/5406/t/1/assets/skinCustom.css?241" rel="stylesheet" type="text/css" media="all" />
--> <script src="http://cdn.shopify.com/s/files/1/0212/5406/t/1/assets/jquery-1.4.2.min.js?241" type="text/javascript"></script>
--> <script src="http://cdn.shopify.com/s/files/1/0212/5406/t/1/assets/jquery.jcarousel.min.js?241" type="text/javascript"></script>
<link href="http://cdn.shopify.com/s/files/1/0212/5406/t/1/assets/style.css?241" rel="stylesheet" type="text/css" media="all" />
<script src="http://cdn.shopify.com/s/files/1/0212/5406/t/1/assets/modernizr.js?241" type="text/javascript"></script>
<script src="http://cdn.shopify.com/s/shopify/option_selection.js?aaf2a68ed9671e345bbc7eef1e63563c51bde6eb" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
ERROR HERE --> $('#mycarousel').jcarousel({ vertical: true, scroll: 1, start: 3 });
});
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="/global/theme-controls.css" type="text/css" />
</head>
我能想象的唯一可能发生的事情是其他脚本文件之一把它搞砸了。但是除了取出其他脚本文件之外,我不确定如何调试它。如果有人遇到类似的问题或对此有一些见解,我将不胜感激。除了不正确的实现(比如不考虑那个脚本),其他问题似乎都没有得到答案。我可能在做一些愚蠢的事情,但我已经研究过无数次了,我看不出它是什么。
谢谢,
艾伦
【问题讨论】:
-
为什么要加载 jquery 两次?一个可能的问题是 jQuery 使用的美元符号。尝试用
jQuery替换它,这样你就有jQuery('#mycarousel')或尝试使用jquery 的noconflict 模式。 api.jquery.com/jQuery.noConflict -
我看了很多遍……我想我需要第二双眼睛。问题就是,两次加载 jquery 会搞砸。我这样做是因为当我最初尝试使用 jcarousel 时,它说它找不到它所依赖的 jquery。所以我自己添加了它,只是假设它还没有加载它。感谢您的回复。我已经尝试了好几个小时。
-
如果您的所有订单都正确并且没有冲突会发生什么。它仍然无法被识别(但您可以在控制台中看到它已加载。
标签: javascript jquery css shopify jcarousel