Wasim
Wasim

Reputation: 5113

Ember.js inserting view into application controller but use another controller for actions

I have default application template where i'm inserting a separate view.

<script type="text/x-handlebars">
...default template....

{{view App.LoginView}}
</script>

<script type="text/x-handlebars" data-template-name="login">
<form {{action login on='submit'}}>
   ...login...
</form>
</script>

I have a view and controller set up for the login view

App.LoginView = Ember.View.extend({
    templateName: 'login'
});
App.LoginController = Ember.Controller.extend({
        actions: {
            login: function() {
                console.log('test');
            }
        }
    }
);

Unfortunately the login action doesn't get sent to App.LoginController but it get sent to the App.ApplicationController. How do I get the actions to forward to the App.LoginController?

Here's a link to the jsbin - http://jsbin.com/ayAnUJi/6/edit

Upvotes: 0

Views: 65

Answers (1)

Wasim
Wasim

Reputation: 5113

Instead of using {{view}} I used {{render}} which actually uses the corresponding views controller.

<script type="text/x-handlebars">
...default template....

{{render "login"}}
</script>

Upvotes: 1

Related Questions