defaults

  • property
can.Control.defaults

{Object}

 

Default values for the Control's options.

Object

defaults provides default values for a Control's options. Options passed into the constructor function will be shallowly merged into the values from defaults in setup, and the result will be stored in this.options.

Message = can.Control.extend({
  defaults: {
    message: "Hello World"
  }
}, {
  init: function(){
    this.element.text( this.options.message );
  }
});

new Message( "#el1" ); //writes "Hello World"
new Message( "#el12", { message: "hi" } ); //writes hi