例如这里 http://jsfiddle.net/tobikko/ysFC6/10/
我如何真正找出 OptionValuePath 和 OptionLabelPath 的内容?如您所见,下拉列表中有一个列表,但值不可见。
在这种情况下,我知道它应该是 OptionLabelPath: "content.firstName" 但如果我不知道怎么办?
我创建了 focusOut 函数来检查视图的内容,它看起来像这样
在我遇到问题的真实应用程序中,内容中的每个对象都不包含ember1340135889380_meta 对象或 __proto部分。那是问题吗?我如何解决它?
<script type="text/x-handlebars">
{{view App.SelectView }}
<p>Selected: {{App.selectedPersonController.person.fullName}}
(ID: {{App.selectedPersonController.person.id}})</p>
</script>
window.App = Ember.Application.create();
App.SelectView = Ember.Select.extend({
contentBinding: "App.peopleController",
selectionBinding: "App.selectedPersonController.person",
optionLabelPath: "firstName",
optionValuePath: "id",
prompt: "select",
focusOut: function () {
var test = this.get('content');
}
})
App.Person = Ember.Object.extend({
id: null,
firstName: null,
lastName: null,
fullName: function() {
return this.get('firstName') + " " + this.get('lastName');
}.property('firstName', 'lastName').cacheable()
});
App.selectedPersonController = Ember.Object.create({
person: null
});
App.peopleController = Ember.ArrayController.create({
content: [
{
id: 1,
firstName: 'Yehuda',
lastName: 'Katz'},
{
id: 2,
firstName: 'Tom',
lastName: 'Dale'},
{
id: 3,
firstName: 'Peter',
lastName: 'Wagenet'},
{
id: 4,
firstName: 'Erik',
lastName: 'Bryn'}
]
});