-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidation-yet-another.html
More file actions
58 lines (58 loc) · 1.8 KB
/
Copy pathvalidation-yet-another.html
File metadata and controls
58 lines (58 loc) · 1.8 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
55
56
57
58
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone-min.js"></script>
<script>
var Person = new Backbone.Model({name: 'Jeremy'});
Person.validate = function(attrs) {
console.log("Validation Called!");
if(!attrs.name) {
console.log("1");
//return "Whatever";
}
if(!attrs) {
console.log("2");
//return "Whatever";
}
if(attrs == 'Russell') {
console.log("3");
//return "Whatever";
}
if(attrs.name == 'Russell2') {
console.log("4");
//return "Whatever";
}
if(attrs.title === undefined) {
console.log("5");
//return "Whatever";
}
if(attrs.name === undefined) {
console.log("6");
//return "Whatever";
}
};
Person.set({name: 'Samuel'}, {validate: true});// Calls validation
//Person.set('name', 'Samuel', {validate: true}); // Calls validation
// Person.unset('name', {validate: true}); // Calls validation
// Person.unset('name', {validate: true}); // Calls validation
// Person.unset('name', { silent: true });//Works
// Person.unset('name', {validate: true});
// Person.unset('name');
//Person.set({name: 'Russell'}); // Works
//Person.set('name', 'Russell', {validate: true}); // Not working
//Person.set({name: 'Russell1'}, {validate: true}); // Not working, but calls validation?
Person.set({"name":'Russell2'}, {validate: true}); // Dopesn't work, but calls validation?
//Person.set({name: 'Russell'}); // Works
//Person.set({"name": 'Russell'}); // Works
//Person.set({"name": 'Russell'}); // Works
//Person.set({'name': 'Russell'}); // Works
console.log(Person.get('name'));
</script>
</body>
</html>