Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
TypeError: JS.Class is not a constructor
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  13 messages - Collapse all  -  Translate all to Translated (View all originals)
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:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Patrik Gmitter  
View profile  
 More options Oct 29 2012, 6:40 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Coglan  
View profile  
 More options Oct 29 2012, 6:49 pm
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Patrik Gmitter  
View profile  
 More options Oct 29 2012, 6:53 pm
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Patrik Gmitter  
View profile  
 More options Oct 29 2012, 7:36 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Coglan  
View profile  
 More options Oct 29 2012, 7:44 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Patrik Gmitter  
View profile  
 More options Oct 29 2012, 7:49 pm
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 ?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Patrik Gmitter  
View profile  
 More options Oct 29 2012, 7:52 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Anthony Rowlands  
View profile  
 More options Oct 29 2012, 7:53 pm
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

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Patrik Gmitter  
View profile  
 More options Oct 29 2012, 8:04 pm
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 :)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Patrik Gmitter  
View profile  
 More options Oct 29 2012, 8:21 pm
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Coglan  
View profile  
 More options Oct 29 2012, 9:05 pm
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:

> 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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Patrik Gmitter  
View profile  
 More options Oct 30 2012, 3:55 am
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', ...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Patrik Gmitter  
View profile  
 More options Oct 30 2012, 5:11 am
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »