javascriptcanjscanjs-control

Defaults in CanJS controller constructor


I have a controller that is similar to:

var TheController = can.Control.extend({
    defaults: {
    field: undefined
},

"pluginName": "theControllerPlugin",
},
{
"init" : function(element, options) {
    field = options["fieldInOptions"];

Right now this field is acting essentially as a static variable. I would prefer it acted as an instance variable. Is this possible and what is the syntax in canJS?


Solution

  • The syntax is this.options.field, any default property can be accessed with this.options.defaultProperty.