1

The following view is giving me "Object doesn't support prop or method jCarouselLite". I have an almost identical page using plain html which works. Am I loading the javascript properly?

@using System.Web.Script.Services
@{
    ViewBag.Title = "Home Page";
}

<script src="@Url.Content("~/Scripts/jquery-2.0.3.js")"></script>
<script src="@Url.Content("/Scripts/jcarousellite_1.0.2.js")"></script>

<script type="text/javascript">
    $(function () {
        // Add Carousel plugin to rotate images
        $(".anyClass").jCarouselLite({
            visible: 1,
            auto: 3000,
            speed: 800,
            btnNext: ".next",
            btnPrev: ".prev"
        });

    });
</script>

<button class="prev"><<</button>
<button class="next">>></button>
<div class="anyClass">
    <ul>
        <li><img src="/gallery/slide-1.jpg" width="250" height="150"></li>
        <li><img src="/gallery/slide-2.jpg" width="250" height="150"></li>
        <li><img src="/gallery/slide-3.jpg" width="250" height="150"></li>
    </ul>
</div>
1
  • I think you've got an answer below. One more tip I would like to tell you. It is always add your custom scripts in a bundle. It will make Shared Layout look very clean. Commented Dec 21, 2013 at 16:30

2 Answers 2

3

Probably your jcarousellite jquery plugin does't load. One possible reason is that it hasn't ~ sign

<script src="@Url.Content("/Scripts/jcarousellite_1.0.2.js")"></script>

And it should be this:

<script src="@Url.Content("~/Scripts/jcarousellite_1.0.2.js")"></script>

If your page isn't located in the root of site, then it can doesn't find it.

You can check in browser Developer tools, what is the url for JQuery and what is for jcarousellite plugin. I suppose they will be different.

Sign up to request clarification or add additional context in comments.

Comments

0
@using System.Web.Script.Services
@{
    ViewBag.Title = "Home Page";
}

<script src="@Url.Content("~/Scripts/jquery-2.0.3.js")"></script>
<script src="@Url.Content("/Scripts/jcarousellite_1.0.2.js")"></script>

    enter code here

<script type="text/javascript">
    $(function () {
        // Add Carousel plugin to rotate images
        $(".anyClass").jCarouselLite({
            visible: 1,
            auto: 3000,
            speed: 800,
            btnNext: ".next",
            btnPrev: ".prev"
        });

    });
</script>

<button class="prev"><<</button>
<button class="next">>></button>
<div class="anyClass">
    <ul>
        <li><img src="/gallery/slide-1.jpg" width="250" height="150"></li>
        <li><img src="/gallery/slide-2.jpg" width="250" height="150"></li>
        <li><img src="/gallery/slide-3.jpg" width="250" height="150"></li>
    </ul>
</div>

1 Comment

While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.