Assign/Create controller while creating Ember View

var view = Ember.View.extend({

 templateName: 'some',
//action: 'save',
//click: function () { this.triggerAction(); },
init: function () {
 this._super();
this.set('controller', App.SomeController.create())
 }

});
view.create().appendTo("#divMain");

Here i am creating the view and appending to a div, however here i have to explicity set the controller this.set('controller', App.SomeController.create())

Is it possible to implicitly assign the controller while creating view?

Answers


No, that's kind of going backwards.

View's don't "have" a controller. Controller's "manage" a view. And the majority of time the parent controller is managing the view. Think of all of the reusable items, input helper, link-to etc, all views, backed by their parent controller.

That being said when you visit a route Ember hooks up the template to the view/controller backing that route. Often these are default implementations and you haven't specified anything different.

Here's the controller property on the Ember View.

  /**
    The controller managing this view. If this property is set, it will be
    made available for use by the template.

    @property controller
    @type Object
  */
  controller: Ember.computed(function(key) {
    var parentView = get(this, '_parentView');
    return parentView ? get(parentView, 'controller') : null;
  }).property('_parentView'),

Need Your Help

Modal popup with redirect button

javascript css modal-dialog

I am sure this is simple, but I am not sure how to achieve this in a simple manner. When users go to mysite.com I would like for a modal to popup first. Inside the modal I need to have three buttons,

Programmatically slide to next Panorama item

windows-phone-7

Is it possible to programmatically move from one panorama page/item to the next and get the same kind of animated sliding effect you get when sliding with a finger?