title: get attribute in backbone model
body: <p>i have a model extend Backbone.Model and have an array attribute named 'labels', by default labels is empty, but later on will filled with data in second function and used in third function, however I had problem to access the 'labels', here is my code</p>
  
  <pre><code>  class GroupTreatmentGraphModel extends Backbone.Model
  
      initialize: () -&gt;
  
      defaults:
        type : 'bar'
        labels: []    
        yFormatter: (y) -&gt; y + ' counts'
        xFormatter:(x) -&gt;  
          for p,q of labels   &lt;-- get error msg: ReferenceError: labels is not defined
            console.log "lp=#{p}, lq=#{q}"
          labels[parseInt(x)]
  
      setData: (cid, data) -&gt;
        tmp=@get('labels')
        console.log "1. get series, label.length="+tmp.length        &lt;-- works fine here
        series = _.find @get('series'), (item) -&gt; item  .cid == cid
        series.setData(data)
  
        countDone = _.countBy @get('series'), (item) -&gt; if item.get('data')? then 'done' else 'notdone'
        if countDone.done == @get('series').length
          @setLabels(data)      
          @set('done', true)
  
      setLabels: (data) -&gt;
          lbl = []
          for k,v of data
            if typeof(v.z) isnt "undefined" &lt;-- for example: k=0, v.x=0, v.z='hell..o,worm!'
              lbl[parseInt(v.x)] = v.z
  
          @set('labels', lbl)
          tmp = @get('labels') 
          console.log "label length="+ tmp.length  &lt;-- works fine here
  
      sync: () -&gt;
        callback = (err, response, cid) =&gt;
          console.log err if err
          @setData(cid, response) if response
  
        series = @get('series')
        if series
          _.each series, (singleSeries) -&gt;
            $.ajax
              cache: false
              type: 'GET'
              url: singleSeries.get('uri')
              dataType: 'json'
              error: (jqxhr) -&gt;
                callback jqxhr, null, singleSeries.cid
              success: (response) -&gt;
                callback null, response, singleSeries.cid
  
    return GroupTreatmentGraphModel
  </code></pre>
  
  <p>and my app code is:</p>
  
  <pre><code>graph = new GroupTreatmentGraphModel
    position: 2
    title: 'SM Total vs Success By Group-Treatment'
    series: [
      new SeriesData
        name: 'gtt'
        color: 'steelblue'
        uri: '/api/gtt'
      new SeriesData
        name: 'gts'
        color: 'lightblue'
        uri: '/api/gts'  
    ]
  </code></pre>
  
  <p>Thanks!</p>