Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught ReferenceError: Class is not defined?

Tags:

javascript

I'm curious to know why I'm getting this error? I've copied it exact from the website beezid.com (carousel.js) file, and I'm trying to get the same slide as them onto my website to update it.. As you can see I'm having issues with this?? Their site doesn't come up with this error?

carousel.js:26 Uncaught ReferenceError: Class is not defined

Carousel = Class.create(Abstract, {
    initialize: function (scroller, slides, controls, options) {
        this.scrolling  = false;
        this.scroller   = $(scroller);
        this.slides     = slides;
        this.controls   = controls;
        this.menu       = false;
        this.menuTitleLen = 20;
like image 238
Dee Henderson Avatar asked Mar 08 '12 01:03

Dee Henderson


2 Answers

Class is not a JavaScript type, so you can't use it. That web site is probably using some third party library that provides a Class type to simplify some types creation etc.

From a quick inspection of the source code it is apparent that this site uses:

  • Scriptaculous and
  • Prototype

I think Prototype has a Class type. Here is a link to Prototype's tutorial on javascript "classes" and inheritance: http://prototypejs.org/learn/class-inheritance

like image 180
Strelok Avatar answered Oct 17 '22 00:10

Strelok


add

<script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.2.0/prototype.js"></script>

You could use Prototype(http://prototypejs.org/) which is a library. Then the issue is resolved.

like image 39
Sprout Avatar answered Oct 17 '22 01:10

Sprout