This library looks very promising and I am trying to play with it, but
I'm confused about how to structure my code.
Right now I have my own object structure, like
"MyUberObject.widgets.MyWidget," which I define as functions and put
methods on the prototypes etc. Then when I want to use one of those
objects on a specific page, I do something like this:
<script>
var myObject = null;
$(document).ready(function() {
myObject = new MyUberObject.widgets.MyWidget();
});
</script>
So, I have tried converting these "classes" into JSClasses, but it
looks like you have to do everything, including calling new, on a
Class INSIDE the JS.require() call or else you will get a "undefined
is not a function" error. So I can't figure out how you're supposed to
define a class in one file and instantiate it in another, on the
document ready event.
Can someone clarify how this is supposed to be done?
So, I have tried converting these "classes" into JSClasses, but it
looks like you have to do everything, including calling new, on a
Class INSIDE the JS.require() call or else you will get a "undefined
is not a function" error. So I can't figure out how you're supposed to
define a class in one file and instantiate it in another, on the
document ready event.
Can someone clarify how this is supposed to be done?
On Dec 7, 2:31 am, James Coglan <jcog...@gmail.com> wrote:
$(document).ready(function() {
JS.require('JS.Class', function() {
myWidget = new MyUberObject.widget.MyWidget();
});
});
I guess because of the asynchronous loading, you have to wait for one
of the library's ready events, but is it correct to require JS.Class
in order to do this?
Thanks for the help, I'm excited to start using it. But the
documentation could benefit greatly from examples, and there is not
much out there on the web about this library. Seems odd as it looks
about 4 years old...
Are there examples somewhere? Or can you give me some quick advice? I
don't want to wait for a blog post...
Hmm I seem to have gotten it to work by doing this:
$(document).ready(function() {
JS.require('JS.Class', function() {
myWidget = new MyUberObject.widget.MyWidget();
});
});
I'm sure my code isn't quite right yet, so I am very much looking
forward to that blog post!
On Dec 7, 7:02 am, James Coglan <jcog...@gmail.com> wrote:
Any ETA on that blog post?
I am very much enjoying the library. Thank you so much for writing
this... the world really needs a simple javascript class framework
like this!
Any ETA on that blog post?