【发布时间】:2013-07-30 13:46:22
【问题描述】:
我一直想知道如何在 Ember.js 中更改 HTML 变量的值。我想要做的是,当我单击 编辑按钮 时,我想更改 readonly 的值并使其可读在使用视图 Ember.TextField 的文本字段上。
代码如下:
<div id="list_container">
<h2>Contacts:</h2>
<ul id="people_List">
{{#each person in controller}}
<li {{bindAttr class='isEditing:red'}}>
<!-- here where Im trying to use the value to switch the value from a html variable -->
{{view Ember.TextField valueBinding="person.name" readonly='isEditing'}}
{{view Ember.TextField valueBinding="person.birthday" readonly='isEditing'}}
{{view Ember.TextField valueBinding="person.telephone" readonly='isEditing'}}
<button {{action edit}}>Edit</button>
<button {{action details}}>Details</button>
<button {{action remove}}>Remove</button>
</li>
{{/each}}
</ul>
</div>
Schedule.PeopleController = Ember.ArrayController.extend({
itemController: 'Person'
});
Schedule.PersonController = Ember.ObjectController.extend({
isEditing: true,
edit : function () {
this.toggleProperty('isEditing');
console.log(this.get('isEditing'));
},
details : function () {
console.log("Details was clicked!!");
},
remove : function () {
console.log("Remove was clicked!!");
}
});
我避免使用:
{{if}}
...HTML CODE...
{{else}}
...HTML CODE...
{{/if}}
【问题讨论】:
标签: javascript html user-interface ember.js