Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think your problem is right here:</p> <pre><code>var WorkoutSectionSlide = Parse.View.extend( { tag : 'div', className : 'sectionPreview', attributes : {} // &lt;----------------- This doesn't do what you think it does </code></pre> <p>Everything that you put in the <code>.extend({...})</code> ends up in <code>WorkoutSectionSlide.prototype</code>, they aren't copied to the instances, they're shared by all instances through the prototype. The result in your case is that you have one <code>attributes</code> object that is shared by all <code>WorkoutSectionSlide</code>s.</p> <p>Furthermore, the view's <a href="http://documentcloud.github.com/backbone/#View-attributes" rel="nofollow"><code>attributes</code></a> are only used while the the object is <a href="https://github.com/documentcloud/backbone/blob/master/backbone.js#L1168" rel="nofollow">being constructed</a>:</p> <pre><code>var View = Backbone.View = function(options) { this.cid = _.uniqueId('view'); this._configure(options || {}); this._ensureElement(); this.initialize.apply(this, arguments); this.delegateEvents(); }; </code></pre> <p>The <a href="https://github.com/documentcloud/backbone/blob/master/backbone.js#L1291" rel="nofollow"><code>_ensureElement</code></a> call is the thing that uses <code>attributes</code> and you'll notice that it comes before <code>initialize</code> is called. That order combined with the prototype behavior is why your attribute shows up on the <em>next</em> instance of the view. The <code>attributes</code> is really meant for static properties, your <code>this.$el.attr('tooltip', ...)</code> solution is a good way to handle a dynamic attribute.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload