Ember.Component isolation


#1

I have developed a calendar/datepicker widget as an Ember.Component however I’m having issues when using more than one instance on a page.

It seems that there is no isolation in place - navigating through one calendar also updates any other calendars on the page. I’m assuming it’s because the view objects are being re-used, so any properties on that view are shared between all instances.

Is that the desired behaviour? If so, perhaps it should be mentioned in the docs somewhere.

If views are always re-used in this way, what is the correct Ember way to create isolated components?


#2

Take a look at this PR: https://github.com/emberjs/ember.js/pull/3080. Might be the same issue?


#3

Thanks. I checked out your patched branch but I’m still seeing the same issue.

Perhaps there is something else going on here, I’ll see if I can reduce the code down to a JSFiddle.


#4

@lookingsideways Show an example, then its easier for people to help you :slight_smile:


#5

This issue turned out to be my own fault. I was assigning empty arrays directly on the prototype instead of creating them during initialisation, so each instance was modifying arrays on the prototype instead of their own variables.

Now that I have it working i haven’t seen any immediately obvious differences between the patched version mentioned above and the current ember behaviour.