2

How can I retreive the "current instance" of my view (defined as TextView) in Ember.js app?

If I get it correctly, the router manages instantiating textView with correct context (I can access it in the handlebars template as {{content}}). Basically, I have several contacts in my messaging app and I need to hold array of messages for each of them.

View:

App.TextView = Ember.View.extend({
    templateName : 'text',
    messages : [],
});

Router:

send : Ember.Route.extend({
    route:'/send',
    connectOutlets:function (router) {
        var conversationController = router.get('conversationController'),
             contact = conversationController.get('content');
        // contact is my context, it's ok here
        conversationController.connectOutlet('text', contact);
    }
)};
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Pavel S.
  • 11,892
  • 18
  • 75
  • 113
  • 1
    a TextView instance is created and returned after each call to 'conversationController.connectOutlet('text', contact)'. Be warned here, I don't know if it's expected, but the messages property wil be shared between all view instances here. – sly7_7 Aug 16 '12 at 15:15
  • `conversationController.get('view')` will return the current instance of your `TextView`. – Manoharan Aug 17 '12 at 04:41

1 Answers1

1

When connectOutlets is called on the conversationController controller, a TextView is created and set as a property on the conversationController, with the name of the Outlet:

If the Outlet has no name, it will be called "view":

Ygg
  • 3,798
  • 1
  • 17
  • 23