例はこちら 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'}
]
});