0

我在实现我的应用程序时遵循了 ember 官方指南,但我收到了这个错误。发出操作时,没有处理事件“addSite”{{view Ember.TextFieldplaceholder="Insert new site name" valueBinding="newName" action="addSite"}}

我的代码 index.html:

<script type="text/x-handlebars" data-template-name="sites">
<ul>
    {{#each site in controller itemController="site"}}
    <li>
        {{#linkTo 'sites.site' site}} {{site.siteName}} {{/linkTo}}
    </li>
    {{/each}}
</ul>
<div>
    {{view Ember.TextField placeholder="Insert new site name"
      valueBinding="newName" action="addSite"}}
</div>


</script>

脚本:

 WebApp.Router.map(function () {
    this.resource('sites', { path: '/' } , function() {
        this.route('site', { path: ':site_id' })
    });
});

WebApp.SitesRoute = Ember.Route.extend({
    model: function() {
        return WebApp.Site.find();
    }
});

WebApp.SitesContoller = Ember.ArrayController.extend({

addSite: function() {
    var newName = this.get('newName');
    var site = WebApp.Site.createRecord({
        siteName: newName
    });

    //Clear text field
    this.set('newName','');

    ////Save the new model
    site.save();

}



 });


WebApp.Site = DS.Model.extend({
id: DS.attr('integer'),       
siteName : DS.attr('string'), 
secretKey: DS.attr('string'), 
publicKey: DS.attr('string'), 
userIdentification : DS.attr('string') 

 });
4

0 回答 0