TypeError: JS.Class is not a constructor
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
Patrik Gmitter <pa... @patie.info>
Date: Mon, 29 Oct 2012 15:40:34 -0700 (PDT)
Local: Mon, Oct 29 2012 6:40 pm
Subject: TypeError: JS.Class is not a constructor
Hi, im trying create class.. but i have problem on the start :-)
index.php // loader-browser.js - loaded ok ... <script type="text/javascript" src="/bundles/web/js/jquery. js"> <script type="text/javascript"> $JSCLASS_PATH = './bundles/web/js/jsclass/'; </script> <script type="text/javascript" src="/bundles/web/js/jsclass/loader-browser.js"> <script type="text/javascript" src="/bundles/web/js/test.js"> .... ---------------------------------------------------------------------------
test.js
JSCLASS_PATH = '/bundles/web/js/jsclass/';
var Animal = new JS.Class({ initialize: function(name) { this.name = name; },
speak: function(things) { return 'My name is ' + this.name + ' and I like ' + things; } });
---------------------------------------------------------------------------
*console output
TypeError: JS.Class is not a constructor [Break On This Error] speak: function(things) {*
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
James Coglan <jcog... @gmail.com>
Date: Mon, 29 Oct 2012 22:49:31 +0000
Local: Mon, Oct 29 2012 6:49 pm
Subject: Re: TypeError: JS.Class is not a constructor
The problem with the code below is that you don't actually load JS.Class --
either add jsclass/core.js after loader-browser.js or use
JS.require('JS.Class', function() { ... }) to load it.
On 29 October 2012 22:40, Patrik Gmitter <pa... @patie.info> wrote:
> index.php // loader-browser.js - loaded ok
> ...
> <script type="text/javascript" src="/bundles/web/js/jquery.
> **js">
> <script type="text/javascript">
> $JSCLASS_PATH = './bundles/web/js/jsclass/';
> </script>
> <script type="text/javascript" src="/bundles/web/js/jsclass/**
> loader-browser.js">
> <script type="text/javascript" src="/bundles/web/js/test.js">
> ....
> ------------------------------**------------------------------**
> ---------------
> test.js
> JSCLASS_PATH = '/bundles/web/js/jsclass/';
> var Animal = new JS.Class({
> initialize: function(name) {
> this.name = name;
> },
> speak: function(things) {
> return 'My name is ' + this.name + ' and I like ' + things;
> }
> });
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Patrik Gmitter <pa... @patie.info>
Date: Mon, 29 Oct 2012 15:53:12 -0700 (PDT)
Local: Mon, Oct 29 2012 6:53 pm
Subject: Re: TypeError: JS.Class is not a constructor
ah JS.Class in require.. im tried JS.Core... :) THANK YOU
On Monday, 29 October 2012 23:49:32 UTC+1, James Coglan wrote:
> The problem with the code below is that you don't actually load JS.Class > -- either add jsclass/core.js after loader-browser.js or use > JS.require('JS.Class', function() { ... }) to load it.
> On 29 October 2012 22:40, Patrik Gmitter <pa... @patie.info <javascript:>>wrote:
>> index.php // loader-browser.js - loaded ok >> ... >> <script type="text/javascript" src="/bundles/web/js/jquery. >> **js"> >> <script type="text/javascript"> >> $JSCLASS_PATH = './bundles/web/js/jsclass/'; >> </script> >> <script type="text/javascript" src="/bundles/web/js/jsclass/** >> loader-browser.js"> >> <script type="text/javascript" src="/bundles/web/js/test.js"> >> .... >> ------------------------------**------------------------------** >> ---------------
>> test.js
>> JSCLASS_PATH = '/bundles/web/js/jsclass/';
>> var Animal = new JS.Class({ >> initialize: function(name) { >> this.name = name; >> },
>> speak: function(things) { >> return 'My name is ' + this.name + ' and I like ' + things; >> } >> });
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Patrik Gmitter <pa... @patie.info>
Date: Mon, 29 Oct 2012 16:36:13 -0700 (PDT)
Local: Mon, Oct 29 2012 7:36 pm
Subject: Re: TypeError: JS.Class is not a constructor
and can define module/bundle in My namespace ? (sry i dont want create many posts)
i trying something like that - but dont work
console output
*Error: Expected package at /bundles/web/js/model/class.cart.js to define My.Cart*
-------------------------------------
JS.Packages(function () { with (this) {
file("/bundles/web/js/lib/jquery.js") .provides('jQuery');
file("/bundles/web/js/model/class.cart.js") .provides("My.Cart") .requires("JS.Class") .requires("jQuery");
}
});
JS.require('JS.Class', 'My.Cart', function () {
-------------------------------------------------------------------- *class.cart.js*
var My = My || {};
JS.require('JS.Class', function () {
My.Cart = new JS.Class('CartClass',{
.....
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
James Coglan <jcog... @gmail.com>
Date: Mon, 29 Oct 2012 23:44:26 +0000
Local: Mon, Oct 29 2012 7:44 pm
Subject: Re: TypeError: JS.Class is not a constructor
On 29 October 2012 23:34, Patrik Gmitter <pa... @patie.info> wrote:
> and can define module/bundle in My namespace ? (sry i dont want create
> many posts)
> var My = My || {};
> JS.require('JS.Class', function () {
> My.Cart = CartClass = new JS.Class('CartClass',{
Try removing the JS.require() line from this file. It's asynchronous and
may mean that when the file is done executing, My.Cart will not be defined.
You've already expressed the dependency in your package manifest so you
don't need to do it in the source files as well.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Patrik Gmitter <pa... @patie.info>
Date: Mon, 29 Oct 2012 16:49:25 -0700 (PDT)
Local: Mon, Oct 29 2012 7:49 pm
Subject: Re: TypeError: JS.Class is not a constructor
i remove
JS.Packages(function () { with (this) {
file("/bundles/web/js/lib/ jquery.js") .provides('jQuery');
file("/bundles/web/js/model/class.cart.js") .provides("My.Cart") .requires("JS.Class") .requires("jQuery");
}
});
now its only in manifest,js
but always the same error.. its possible going with this like namespaced way ?
On Tuesday, 30 October 2012 00:44:26 UTC+1, James Coglan wrote:
> On 29 October 2012 23:34, Patrik Gmitter <pa... @patie.info <javascript:>>wrote:
>> and can define module/bundle in My namespace ? (sry i dont want create >> many posts)
>> var My = My || {};
>> JS.require('JS.Class', function () {
>> My.Cart = CartClass = new JS.Class('CartClass',{
> Try removing the JS.require() line from this file. It's asynchronous and > may mean that when the file is done executing, My.Cart will not be defined. > You've already expressed the dependency in your package manifest so you > don't need to do it in the source files as well.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Patrik Gmitter <pa... @patie.info>
Date: Mon, 29 Oct 2012 16:52:48 -0700 (PDT)
Local: Mon, Oct 29 2012 7:52 pm
Subject: Re: TypeError: JS.Class is not a constructor
ok problem was in var My = My || {}; ... with My = My || {};without var works perfect :)
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Anthony Rowlands <draftoma... @gmail.com>
Date: Mon, 29 Oct 2012 17:53:44 -0600
Local: Mon, Oct 29 2012 7:53 pm
Subject: Re: TypeError: JS.Class is not a constructor
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Patrik Gmitter <pa... @patie.info>
Date: Mon, 29 Oct 2012 17:04:44 -0700 (PDT)
Local: Mon, Oct 29 2012 8:04 pm
Subject: Re: TypeError: JS.Class is not a constructor
thanks :)
On Tuesday, 30 October 2012 00:53:44 UTC+1, Anthony wrote:
> Since I had very similar issues when I started using JS.Class, I'll > quickly point you to a conversation James and I had on this list titled "How > to integrate JS.Class<https://groups.google.com/forum/?fromgroups=#!topic/jsclass-users/Ooe... >" > and his related blog article about JS.Packages<http://blog.jcoglan.com/2012/01/23/organizing-a-project-with-js-packa... > which > clears a lot of this up with examples. I highly recommend reading the blog > to get insight into the design decisions that went into the package loading > system.
> Good luck, > Anthony
> On Mon, Oct 29, 2012 at 5:52 PM, Patrik Gmitter <pa... @patie.info<javascript:> > > wrote:
>> ok problem was in var My = My || {}; ... with My = My || {};without var >> works perfect :)
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Patrik Gmitter <pa... @patie.info>
Date: Mon, 29 Oct 2012 17:21:36 -0700 (PDT)
Local: Mon, Oct 29 2012 8:21 pm
Subject: Re: TypeError: JS.Class is not a constructor
last one question
its possible loading jquery plugins with JS.require or its better to load it classic with <script ... ?
for example https://github.com/needim/noty/blob/master/js/noty/jquery.noty.js
On Tuesday, 30 October 2012 01:04:44 UTC+1, Patrik Gmitter wrote:
> thanks :)
> On Tuesday, 30 October 2012 00:53:44 UTC+1, Anthony wrote:
>> Since I had very similar issues when I started using JS.Class, I'll >> quickly point you to a conversation James and I had on this list titled "How >> to integrate JS.Class<https://groups.google.com/forum/?fromgroups=#!topic/jsclass-users/Ooe... >" >> and his related blog article about JS.Packages<http://blog.jcoglan.com/2012/01/23/organizing-a-project-with-js-packa... > which >> clears a lot of this up with examples. I highly recommend reading the blog >> to get insight into the design decisions that went into the package loading >> system.
>> Good luck, >> Anthony
>> On Mon, Oct 29, 2012 at 5:52 PM, Patrik Gmitter <pa... @patie.info> wrote:
>>> ok problem was in var My = My || {}; ... with My = My || {};without var >>> works perfect :)
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
James Coglan <jcog... @gmail.com>
Date: Tue, 30 Oct 2012 01:05:28 +0000
Local: Mon, Oct 29 2012 9:05 pm
Subject: Re: TypeError: JS.Class is not a constructor
On 30 October 2012 00:21, Patrik Gmitter <pa... @patie.info> wrote:
Sure, just state which object they provide.
file('noty.js').provides('jQuery.noty').requires('jQuery');
JS.require('jQuery.noty' ...)
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Patrik Gmitter <pa... @patie.info>
Date: Tue, 30 Oct 2012 00:55:14 -0700 (PDT)
Local: Tues, Oct 30 2012 3:55 am
Subject: Re: TypeError: JS.Class is not a constructor
yes i tried this but
- when i have
file("/bundles/web/js/plugin/jquery.noty.js") .provides('jQuery.noty') .requires("jQuery");
---- use noty({ type:'success', .... // like in noty manual
ReferenceError: noty is not defined
noty({ type:'success', ...
----------------
-use jQuery.noty({ type:'success', ....
TypeError: jQuery.noty is not a function
...ery.noty({ type:'success', ...
--------------
wen i load it with <script ... of cource works as in manual say - noty({ type:'success', ...
On Tuesday, 30 October 2012 02:05:28 UTC+1, James Coglan wrote:
> On 30 October 2012 00:21, Patrik Gmitter <pa... @patie.info <javascript:>>wrote:
>> last one question
>> its possible loading jquery plugins with JS.require or its better to load >> it classic with <script ... ?
>> for example >> https://github.com/needim/noty/blob/master/js/noty/jquery.noty.js
> Sure, just state which object they provide.
> file('noty.js').provides('jQuery.noty').requires('jQuery');
> JS.require('jQuery.noty' ...)
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Patrik Gmitter <pa... @patie.info>
Date: Tue, 30 Oct 2012 02:11:40 -0700 (PDT)
Local: Tues, Oct 30 2012 5:11 am
Subject: Re: TypeError: JS.Class is not a constructor
when i hack noty.js
BEFORE
// Helpers function noty(options) {
AFTER
// Helpers noty =function noty(options) {
and use
file("/bundles/web/js/plugin/jquery.noty.js") .provides('noty') .requires("jQuery");
IT WORKS... But too bad that I had to modify the plugin code.. this will case problem with updates.. its there other way to do it ? thx
You must
Sign in before you can post messages.
You do not have the permission required to post.