-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathview1.html
43 lines (32 loc) · 1.08 KB
/
view1.html
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
32
33
34
35
36
37
38
39
40
41
42
43
<html>
<head>
<link rel="stylesheet" href="css/styles.css" />
</head>
<body>
<div id="content" style="font-size: 24px"></div>
<script type="text/javascript" src="lib/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="lib/underscore-min.js"></script>
<script type="text/javascript" src="lib/backbone-min.js"></script>
<script type="text/javascript">
Employee = Backbone.Model.extend({
urlRoot: "api/employees"
});
$('#content').append('<input id="firstName" type="text"/><br/>');
$('#content').append('<input id="lastName" type="text" /><br/><br/>');
$('#content').append('<button class="save">Save</button>');
employee = new Employee({id: 1});
employee.fetch({
success: function() {
$('#firstName').val(employee.get('firstName'));
$('#lastName').val(employee.get('lastName'));
}
});
$('.save').on('click', function() {
save();
});
function save() {
employee.save({firstName: $('#firstName').val(), lastName: $('#lastName').val()});
}
</script>
</body>
</html>