Weitere ähnliche Inhalte
Ähnlich wie 第6回rest勉強会 アソシエーション編 (20)
第6回rest勉強会 アソシエーション編
- 30. public $belongsTo = array (
'Owner' => array (
'className' => 'User',
'foreignKey' => 'owner',
),
'Assignee' => array (
'className' => 'User',
'foreignKey' => 'assignee'
)
);
Lesson1 サーバサイド開発
■belongsTo
・TodoList.php
- 34. public $hasOne = array (
'TodoList' => array (
'className' => 'TodoList',
'foreignKey' => 'owner'
)
);
■hasOne
・User.php
Lesson1.5 アソシエーションの実験
- 36. public $hasMany = array (
'TodoList' => array (
'className' => 'TodoList',
'foreignKey' => 'owner'
)
);
■hasMany
・User.php
Lesson1.5 アソシエーションの実験
- 37. public $hasMany = array (
'TodoList' => array (
'className' => 'TodoList',
'foreignKey' => 'owner'
)
);
■hasMany
・User.php
Lesson1.5 アソシエーションの実験
変わるのはここだけ!
- 44. onRender : function() {
this.userCollection = new UserCollection();
this.listenTo(this.userCollection,
'reset', this.onLoadUsers, this);
this.userCollection.fetch({reset : true});
},
■ユーザ一覧情報の取得
Lesson2 クライアントサイド開発
ビューの生成前に取得
・todo-layout-view.js
- 46. //ユーザ一覧を表示
showUserList : function($list, userList){
$.each(userList, function(index, userModel) {
$list.append(
"<option value='"
+ userModel.attributes.id + "'>"
+ userModel.attributes.name + "</option>");
});
},
■ユーザ一覧の表示
Lesson2 クライアントサイド開発
ループ回してタグ挿入
・todo-composite-view.js