Basic Sproutcore: class method, class variables help -


this how defining simple class instance variables , instance methods.

exampleclass = sc.object.extend({     foo:undefined,     bar: function() {         this.foo = "hello world";         console.log( this.foo );     } }  // test var testinstance = exampleclass.create(); testinstance.bar();    // outputs 'hello world' 

could me out similar example of class variable (or similar behavoir), , class method?

thanks

a class method/property done like:

exampleclass = sc.object.extend({   foo:undefined,   bar: function() {     this.foo = "hello world";     console.log( this.foo );   } }  exampleclass.mixin({   classfoo: "foo",   classbar: function() {     return "bar";   } }) 

then can access like:

exampleclass.classfoo 

but don't forget when accessing property (or computed property) on instance, need use .get() like:

var example = exampleclass.create(); // example.get('foo'); example.set('foo', 'baz');  // bad!! don't this, or bindings/ observes won't work. example.foo;  example.foo = 'baz'; 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -