forked from jupiterjs/jquerymx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo-update.html
More file actions
54 lines (48 loc) · 1.21 KB
/
demo-update.html
File metadata and controls
54 lines (48 loc) · 1.21 KB
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
51
52
53
54
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Controller Example</title>
<style type='text/css'>
</style>
</head>
<body>
<div id="demo-html">
<form action='' id='createRecipes'>
<input type='text' name='name'/>
<input type='submit' value='Create Recipe'/>
</form>
</div>
<script type='text/javascript' src='../../steal/steal.js'></script>
<script type='text/javascript'>
steal("jquery/controller",
"jquery/model",
"jquery/dom/form_params",
"jquery/dom/fixture",
function(){
$.fixture.delay = 2000;
$.fixture("POST /recipes",function(){
return {};
})
$.Model('Recipe',{
create : "/recipes"
},{});
$.Controller('Creator',{
"{recipe} created" : function(){
this.update({recipe : new Recipe()});
this.element[0].reset();
this.find("[type=submit]").val("Create Recipe")
},
"submit" : function(el, ev){
ev.preventDefault();
var recipe = this.options.recipe;
recipe.attrs( this.element.formParams() );
this.find("[type=submit]").val("Saving...")
recipe.save();
}
});
$('#createRecipes').creator({recipe : new Recipe()})
})
</script>
</body>
</html>