forked from GarethElms/BackboneJSModalView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackbone-form-demo.html
50 lines (38 loc) · 1.15 KB
/
backbone-form-demo.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
44
45
46
47
48
49
50
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Backbone.js Modal Dialog</title>
<link rel="stylesheet" type="text/css" media="screen" href="demo.css" />
<link href="lib/backbone-forms.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="lib/underscore-min.js" type="text/javascript"></script>
<script src="lib/backbone-min.js" type="text/javascript"></script>
<script src="lib/backbone-forms.js"></script>
<script>
var User = Backbone.Model.extend({
schema: {
email: { dataType: 'email'},
name: { dataType: 'Text'}
}
});
var formView = Backbone.View.extend({
render: function() {
var form = new Backbone.Form({
model: this.model
}).render();
$(this.el).append(form.el);
return this;
}
});
$(document).ready(function(){
var myUser = new User();
myUser.set({name:'james',email:'[email protected]'});
var myForm = new formView({model:myUser});
$('body').html(myForm.render().el);
});
</script>
</head>
<body>
</body>
</html>