这里我面临的问题是通过IndexController将我的Ember.TextField绑定到<div id="bindhere"></div>
而不使用模板格式。因为它出现在我的代码的末尾。
这是我的模板
<script type="text/x-handlebars" id="index" > < button {{action "select" on="click"}}>OK </button>
{{outlet}}
</script>
**Here is my Controller**
App = Ember.Application.create();
App.IndexController = Ember.ObjectController.extend({
actions: {
select: function(param1, param2) {
Ember.TextField.create({
classNames: ['btn btn-sm btn-danger glyphicon glyphicon-pencil'],
type: 'button',
attributeBindings: ['value'], value: "New Button",
action: '{{formeditchangefinder}}' ,
onEvent: 'click',
//attributeBindings: ['on'], on: ['click']
eventManager: Ember.Object.create({
click: function(event, view) {
alert("working"+elementname);
}
})
}).append();
}
}
});
我在 JS-Bin http://jsbin.com/dupagi/1/
中添加了以下内容答案 0 :(得分:0)
如果我的问题正确无误 -
查看此Demo
基本上你必须给你想要追加的div提供一个ID -
<div style="bindhere" id="bindhere"></div>
然后 -
App.IndexController = Ember.ObjectController.extend({
actions: {
select: function(param1, param2) {
var bindhere = $('#bindhere');
Ember.TextField.create({
classNames: ['btn btn-sm btn-danger glyphicon glyphicon-pencil'],
type: 'button',
attributeBindings: ['value'], value: "New Button",
action: '{{formeditchangefinder}}' ,
onEvent: 'click',
//attributeBindings: ['on'], on: ['click']
eventManager: Ember.Object.create({
click: function(event, view) {
alert("working"+elementname);
}
})
}).appendTo(bindhere);
}
}
});