Monday, December 29, 2008

[jQuery] Re: define and invoke class inside $(document).ready

Looks fine to me.

Is myClass used in other places (ie outside of your document ready)?
If so, you have to define it outside of document ready or do this

window.myClass = function() {
this.imagesHolder = null;
}


On Dec 29, 7:09 pm, bob <xoxeo...@gmail.com> wrote:
> Is that a correct way to create class utilizing jQuery?
>
> var myClass = null;
>
> $(document).ready(function(){
>         function MyClass(){
>                 this.imagesHolder = null;
>         }
>
>         MyClass.prototype.init = function (){
>                 this.imagesHolder = jQuery("#imgs");
>         }
>
>       myClass = new MyClass();
>
> });

No comments: