DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
  • Infrastructure
  • Legacy
    • can-ejs
    • can-list
    • can-map
      • prototype
        • DEFAULT-ATTR
        • attr
        • bind
        • compute
        • each
        • removeAttr
        • serialize
        • unbind
      • static
        • keys
    • can-map-backup
    • can-map-define
    • can-view-href
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Legacy
  • /
  • can-map
  • /
  • DEFAULT-ATTR
  • / On this page
    • DEFAULT-ATTR

      property

      Specify a default property and value.

      • source

      *

      A value of any type other than a function that will be set as the DEFAULT-ATTR attribute's value.

      Use

      When extending can-map, if a prototype property is not a function, it is used as a default value on instances of the extended Map. For example:

      var Paginate = Map.extend({
          limit: 20,
          offset: 0,
          next: function(){
              this.attr("offset", this.attr("offset")+this.attr("limit"))
          }
      });
      
      var paginate = new Paginate({limit: 30});
      
      paginate.attr("offset") //-> 0
      paginate.attr("limit")  //-> 30
      
      paginate.next();
      
      paginate.attr("offset") //-> 30
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.