1

I know that the obvious answer to this problem would be to check if the jquery and jcarousel scripts were loaded correctly, but I can see the resources in my browser debugger, and thus think that this is not the problem. I cannot seem to get it to run the script:

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<meta name="description" content="Support and Information for the Trail Tracker application" />

<script type="text/javascript" language="javascript" src="../../Scripts/jquery-1.4.2.min.js"></script>
<script type="text/javascript" language="javascript" src="../../Scripts/jquery.jcarousel.min.js"></script>
<link rel="stylesheet" type="text/css" href="../../App_Themes/Default/skin.css" />
   <script type="text/javascript">
    jQuery(document).ready(function () {
        jQuery('#mycarousel').jcarousel({
            // Configuration goes here
        });
    });

Here is the markup that corresponds to the method call:

<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" Runat="Server">
<ul id="mycarousel" class="jcarousel-skin-tango">
<li>yo</li>
<li>soy</li>
</ul>

please help; I have minimal experience with javascript.


No. Basically, your plugin is not binded to jquery.fn.init as it should. What you can do is this: console.dir(jQuery.fn.init.prototype);. This will list all the functions binded to an element. Then check you are loading the plugin properly. Basically, javascript is telling you it cannot find a method with the name jcarousel under the jquery.fn.init.prototype, which most likely implies you are not loading it properly.

Basically all you need is to load the script.

<script type = "text/javascript" src = "../jCarousel.min.js"></script>

Obviously adjust the filename/path according to what you have and you should be good to go.

4

2 回答 2

3

Ok; the guy who actually answered the question but then deleted his answer never posted back, so here is the solution that worked:

I had loaded the jQuery library once in the .master page and once on the .aspx page. I guess they cancelled each other out ~shrug~, because when I removed one reference, everything fell into line.

于 2013-01-02T02:57:27.727 回答
3

不。基本上,您的插件没有jquery.fn.init按应有的方式绑定。你可以做的是:console.dir(jQuery.fn.init.prototype);. 这将列出绑定到一个元素的所有函数。然后检查您是否正确加载插件。基本上,javascript 告诉您它找不到名称jcarousel在 下的方法jquery.fn.init.prototype,这很可能意味着您没有正确加载它。

基本上你只需要加载脚本。

<script type = "text/javascript" src = "../jCarousel.min.js"></script>

显然,根据您所拥有的调整文件名/路径,您应该一切顺利。

于 2012-12-15T18:58:02.743 回答