emberjs/ember.js — Issue #306: Objects as ViewControllers should observe easier view insertions
Author: ppcano
Created: 2011-12-27 16:40:46+00:00
State: open

Creating custom UI requires than ViewControllers listen when the view they are handling has been inserted on the DOM (ex: to take css properties).

I did not find a clean way to get notified about that and ends doing myself on the following way:

```javascript
Ui.ControlledView = Em.Mixin.create({

didInsertElement: function() {
set(this, 'isInsertedElement', true);
}

});

Ui.ViewController = SC.Object.extend({

view: null,

_didInsertElement: function() {
this.didInsertElement();
}.observes('view.isInsertedElement'),

didInsertElement: function() {

}

});
```

I think getting notified for view events could be useful to create complex interactions and the most info the view controllers can manage the better interactions could be created.

Perhaps, there is a easier way or other approach to do that, but i did not find out how.

lg