简体   繁体   中英

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

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM