-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollection.max.html
More file actions
31 lines (31 loc) · 817 Bytes
/
Copy pathcollection.max.html
File metadata and controls
31 lines (31 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script src="jquery-1.11.2.js"></script>
<script src="underscore.js"></script>
<script src="backbone.js"></script>
<script>
var count = 1;
var c = new Backbone.Collection();
c.add([
{ title: 'go to Belgium.', completed: false, age: 50, id: 1 },
{ title: 'go to China.', completed: false, age: 50, id: 2 },
{ title: 'go to Austria.', completed: true, age: 50, id: 3 }
]);
// console.log(c.max()); // Logs: "infinity"
//
// console.log(c.max(function(model) { // Working.
// return model.get('id'); // Gets id attribute, so it can select max
// }));
//
var maximum = c.max(function(model){ // Cannot get working
return model.id;
}).id;
console.log(maximum);
</script>
</body>
</html>