willDestroyElement
HTML
<script src="http://cloud.github.com/downloads/emberjs/ember.js/ember-dfd95de.js"></script>
<script type="text/x-handlebars" >
<ul>
{{#each App.list}}
{{view App.ListItem contentBinding="this"}}
{{/each}}
</ul>
<ul style="position:absolute;right:0;top:0;text-align:right">
{{#each App.log}}
<li>{{this}}</li>
{{/each}}
</ul>
</script>
JavaScript
App = Ember.Application.create({});
App.list = Ember.ArrayProxy.create({
content: [1, 2, 3, 4, 5]
});
App.log = [];
App.ListItem = Ember.View.extend({
tagName: 'li',
render: function(buffer) {
buffer.push(this.content);
},
didInsertElement: function() {
App.log.pushObject('didInsertElement ' + this.content);
},
willDestroyElement: function() {
App.log.pushObject('willDestroyElement ' + this.content);
}
});
Em.run.later(function() {
App.list.popObject();
}, 500);
Em.run.later(function() {
App.list.popObject();
}, 1000);
Em.run.later(function() {
// replace ALL fails to fire willDestroyElement
App.list.set('content', [6,7,8,9]);
}, 2000);