ItemController controller leaking variable


#1

I’ve asked this question also on Stackoverflow. Here is the copied question:

I have an itemController that has two fields: isExpanded and newComment. The isExpanded is working great and binding to each itemController, but the newComment is somehow shared by all the instances of the itemController. And it will only share for the first time. After I submit the new comment, that textarea no longer share the same binding with other textareas, but the rest of the textareas are still mysteriously binding to the same ghost newComment. Why?


#2

Since newComment is an “instantiated object” it’s shared between all instances of your itemController. What you could do is use init to set the default value.

See this issue on how and why this is: https://github.com/emberjs/ember.js/issues/462


#3

Very helpful! Thanks for also pointing to the issue.