-
Notifications
You must be signed in to change notification settings - Fork 31
/
backboneparse.html
75 lines (58 loc) · 1.85 KB
/
backboneparse.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Backbone Parse Example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.1/underscore-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js"></script>
<script src="jquery.parse.js"></script>
<script src="backbone.parse.js"></script>
<script>
//NOT finished just a test
!function(GLOBAL){
var Task, TaskList;
$.parse.init({
app_id : "",
rest_key : ""
});
Task = Backbone.ParseModel.extend({
urlRoot : "tasks"
});
TaskList = Backbone.ParseCollection.extend({
model : Task,
//Todo figure out a way to reference a passed ParseModel's url.
url : 'tasks'
});
GLOBAL.todos = new TaskList;
/* example use */
todos.fetch({
data : {
where : { "body" : { "$ne" : "testing this out"} }
},
success : update,
error : function(){
console.log(arguments);
}
});
function update(){
var first, changes;
first = todos.first();
changes = {
body : "again testing this out ok " + new Date()
};
first.save(changes,{
success : function(){
console.log(arguments);
},
error : function(){
console.log(arguments);
}
});
}
}(window);
</script>
</head>
<body>
</body>
</html>