brainmurphy1
brainmurphy1

Reputation: 1112

jquery jcarousel error: Uncaught TypeError: Object #<Object> has no method 'jcarousel'

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.

Upvotes: 1

Views: 6486

Answers (2)

brainmurphy1
brainmurphy1

Reputation: 1112

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.

Upvotes: 3

flavian
flavian

Reputation: 28511

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.

Upvotes: 3

Related Questions