Javascript 余烬操作未连接到方法

Javascript 余烬操作未连接到方法,javascript,ember.js,Javascript,Ember.js,我有一个问题,应该有一个简单的解决办法。由于某些原因,我的动作助手没有连接到它的方法 这是我的JSBin 代码复制如下以供参考 HTML: JS-Bin JavaScript: var TemplatedViewController = Ember.Object.extend({ templateFunction: null, context: null, viewBaseClass: Ember.View, view: function () {

我有一个问题,应该有一个简单的解决办法。由于某些原因,我的动作助手没有连接到它的方法

这是我的JSBin

代码复制如下以供参考

HTML:


JS-Bin
JavaScript:

var TemplatedViewController = Ember.Object.extend({
    templateFunction: null,
    context: null,
    viewBaseClass: Ember.View,
    view: function () {
        var controller = this;
        var context = this.get('context') || {};
        var args = {
            template: controller.get('templateFunction'),
            controller: controller
        };
        args = $.extend(context, args);
        return this.get('viewBaseClass').extend(args);
    }.property('templateFunction'),
    appendView: function (selector) {
        this.get('view').create().appendTo(selector);
    },
    appendViewToBody: function (property) {
        this.get(property).create().append();
    }
});

var template_source = '<button type="button" class="btn" {{action "button"}}>Click</button>';

var MyController = TemplatedViewController.extend({
    templateFunction: Ember.Handlebars.compile(template_source),
    button: function() {
        console.log('hello world');
    }
});

var controller = MyController.create();

$(function () {
    controller.appendView('#main');
});
var TemplatedViewController=Ember.Object.extend({
templateFunction:null,
上下文:null,
viewBaseClass:Ember.View,
视图:函数(){
var控制器=此;
var context=this.get('context')|{};
变量args={
模板:controller.get('templateFunction'),
控制器:控制器
};
args=$.extend(上下文,args);
返回此.get('viewBaseClass').extend(args);
}.property('templateFunction'),
附录视图:函数(选择器){
this.get('view').create().appendTo(选择器);
},
appendViewToBody:函数(属性){
this.get(property.create().append();
}
});
变量模板_源='单击';
var MyController=TemplatedViewController.extend({
templateFunction:Ember.handlebar.compile(模板源代码),
按钮:函数(){
log('helloworld');
}
});
var controller=MyController.create();
$(函数(){
controller.appendView(“#main”);
});

您需要创建一个余烬应用程序。将以下内容添加到脚本的开头:

App = Ember.Application.create();
App = Ember.Application.create();