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

2008-12-29 Thread Kean
You have to get the execution order right. this is just a declaration, to let javascript know that this function exists MyClass.prototype.init = function (){ this.imagesHolder = jQuery("#imgs"); } jQuery("#imgs") is not executed until you do something like this. var

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

2008-12-29 Thread bob
Yep, I intend to use myClass outside of document ready. I thought that in order to use jQuery as follows this.imagesHolder = jQuery("#imgs"); inside of MyClass I would have to enclose it inside $(document).ready(function(){... so that DOM is ready before invoking MyClass. Is my assumption wrong?

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

2008-12-29 Thread Kean
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 wrote: > Is that a correct way to create class utilizing