it's this line that's the problem:
this.listenTo(Adapt.blocks, 'change:_isComplete', this.setComplete, this);
as it's saying 'any time ANY block's _isComplete
attribute changes, execute this.setComplete
'.
You need to be more specific than that; i.e. you only want to be listening to the _isComplete
change event for blocks associated with the current instance of the blockSlider extension.
Luckily, it looks like there's already a function to give you that list - getAvailableBlocks
- so you should be able to change the above code to:
this.listenTo(this.getAvailableBlocks(), 'change:_isComplete', this.setComplete);
Your setComplete
function also makes the assumption that the block that's just been completed will always be the 'active' block - which probably will be the case the majority of the time but you should still try and avoid making assumptions like that as they can lead to unexpected behaviour (i.e. bugs!)
to be more specific and avoid that sort of problem, look up the _id
of the block that just got set to completed and use that to construct a more specific selector:
setComplete: function(blockModel) {
var blockId = blockModel
.get('_id');
this.$('.blockslider-tab-' + blockId).addClass('complete');
},
Hope this helps.