LoginView takes ApplicationController instead of LoginController


#1

Hi Everybody,

long story short: i do have set up a LoginView (which gets rendered well) with a click event-handler defined. In this handler i want to send this event to the LoginController (which is defined and being loaded with requireJS).

The Problem ist, that it gets sent to the ApplicationController instead of the LoginController.

I’am aware of Naming Conventions. But what am i doing wrong here?

(For “Trial-and-Error” i put the LoginController-Definition inside the LoginView.js; same result. If i could fix the problem with the LoginController being inside the LoginView.js it shouldnt be big deal to move it to the LoginView.js, i guess…)

define([
    "Ember",
    "App",

    "text!Template/LoginTemplate.htm"
], function(Ember, App, LoginTemplate) {

    App.LoginView = Ember.View.extend({
        template: Ember.Handlebars.compile(LoginTemplate),

        click: function(event)
        {
            console.log(this.get("controller"));
            this.get("controller").submit();
        }
    });

    App.LoginController = Ember.Controller.extend({
        submit: function()
        {
            alert("LoginController");
        }
    });

    App.ApplicationController = Ember.Controller.extend({
        submit: function()
        {
            alert("ApplicationController");
        }
    });


    return App.LoginView;
});

Many thanks in Advance for any Tip. I would love to get closer to the concepts of Ember.js!

Cheers,

Fabi.


#2

Okay, took a look again at the Guides (keeping in Mind that if i try hard to do something in Ember.js i probably am doing it the wrong way…):

“In Ember.js, controllers allow you to decorate your models with display logic.”

So, if i would serialize a form and send it to the server, i would do this just in view?