最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jquery jcarousel error: Uncaught TypeError: Object #<Object> has no method 'jcarousel&#39

programmeradmin1浏览0评论

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.

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.

Share Improve this question edited Dec 15, 2012 at 19:07 brainmurphy1 asked Dec 15, 2012 at 18:52 brainmurphy1brainmurphy1 1,1121 gold badge19 silver badges24 bronze badges 2
  • I Think jQuery is not initialized. Check if you can make an "alert('foo');" instead of your jQuery call. This way you can figure out whether jQuery is loaded correctly. – MUG4N Commented Dec 15, 2012 at 18:54
  • It successfully Alerted me "foo": jquery is loaded. I see it and the jcarousel files in my debugger. – brainmurphy1 Commented Dec 15, 2012 at 18:57
Add a ment  | 

2 Answers 2

Reset to default 3

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.

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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论