backbone-nested-attributes 0.3.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Backbone.NestedAttributesModel
|
2
2
|
|
3
|
+
[![build status][1]][2]
|
4
|
+
|
5
|
+
[1]: https://travis-ci.org/dtmtec/backbone-nested-attributes.png
|
6
|
+
[2]: http://travis-ci.org/dtmtec/backbone-nested-attributes
|
7
|
+
|
3
8
|
Add Rails-like nested attributes support for Backbone.Model.
|
4
9
|
|
5
10
|
## Installation
|
@@ -69,7 +74,7 @@ post.get('comments') // returns a Backbone.Collection of Comment models
|
|
69
74
|
When saving data, you can choose whether to send attributes as usual, or with nested attributes support by giving `{ nested: true }` to `save`:
|
70
75
|
|
71
76
|
```javascript
|
72
|
-
post.save({}, { nested: true })
|
77
|
+
post.save({}, { nested: true })
|
73
78
|
```
|
74
79
|
|
75
80
|
This will send data to the server like this:
|
data/Rakefile
CHANGED
@@ -10,6 +10,12 @@ load 'rails/tasks/engine.rake'
|
|
10
10
|
|
11
11
|
Bundler::GemHelper.install_tasks
|
12
12
|
|
13
|
+
task :travis do
|
14
|
+
puts "Starting to run app:jasmine:ci..."
|
15
|
+
system("export DISPLAY=:99.0 && bundle exec rake app:jasmine:ci")
|
16
|
+
raise "#{cmd} failed!" unless $?.exitstatus == 0
|
17
|
+
end
|
18
|
+
|
13
19
|
task :jasmine => 'app:jasmine'
|
14
20
|
|
15
|
-
task :default =>
|
21
|
+
task :default => :travis
|
@@ -65,13 +65,17 @@
|
|
65
65
|
|
66
66
|
function clearDeletedModelsFor(model) {
|
67
67
|
_(model.relations).each(function (relation) {
|
68
|
-
var
|
68
|
+
var collectionOrModel = model.get(relation.key)
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
if (collectionOrModel && collectionOrModel.each) {
|
71
|
+
collectionOrModel.each(function (nestedModel) {
|
72
|
+
clearDeletedModelsFor(nestedModel)
|
73
|
+
})
|
73
74
|
|
74
|
-
|
75
|
+
if (collectionOrModel.deletedModels) {
|
76
|
+
collectionOrModel.deletedModels.reset()
|
77
|
+
}
|
78
|
+
}
|
75
79
|
})
|
76
80
|
}
|
77
81
|
|
@@ -198,4 +202,4 @@
|
|
198
202
|
return BackboneModelPrototype.clear.apply(this, arguments)
|
199
203
|
}
|
200
204
|
})
|
201
|
-
})(Backbone, _)
|
205
|
+
})(Backbone, _)
|
@@ -211,6 +211,22 @@ describe("Backbone.NestedAttributesModel", function() {
|
|
211
211
|
})
|
212
212
|
})
|
213
213
|
|
214
|
+
describe("when synchronizing", function() {
|
215
|
+
beforeEach(function() {
|
216
|
+
jasmine.Ajax.useMock()
|
217
|
+
|
218
|
+
model = new Post({ title: 'Some Title', author: { name: 'Jon Snow' } })
|
219
|
+
model.url = 'http://someapi.com'
|
220
|
+
})
|
221
|
+
|
222
|
+
it("does not raise errors", function() {
|
223
|
+
model.save()
|
224
|
+
|
225
|
+
var request = mostRecentAjaxRequest();
|
226
|
+
request.response({status: 200, responseText: { title: 'Some Title', comments: [] }}) // would raise error
|
227
|
+
})
|
228
|
+
})
|
229
|
+
|
214
230
|
describe("toJSON", function() {
|
215
231
|
beforeEach(function() {
|
216
232
|
model = new Post({ title: 'Some Title', author: { name: 'Jon Snow' } })
|
@@ -697,4 +713,4 @@ describe("Backbone.NestedAttributesModel", function() {
|
|
697
713
|
})
|
698
714
|
})
|
699
715
|
})
|
700
|
-
})
|
716
|
+
})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backbone-nested-attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -36,6 +36,7 @@ extra_rdoc_files: []
|
|
36
36
|
files:
|
37
37
|
- .gitignore
|
38
38
|
- .rvmrc
|
39
|
+
- .travis.yml
|
39
40
|
- Gemfile
|
40
41
|
- LICENSE.txt
|
41
42
|
- README.md
|
@@ -99,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
100
|
version: '0'
|
100
101
|
segments:
|
101
102
|
- 0
|
102
|
-
hash: -
|
103
|
+
hash: -909152891193879280
|
103
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
105
|
none: false
|
105
106
|
requirements:
|
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
109
|
version: '0'
|
109
110
|
segments:
|
110
111
|
- 0
|
111
|
-
hash: -
|
112
|
+
hash: -909152891193879280
|
112
113
|
requirements: []
|
113
114
|
rubyforge_project:
|
114
115
|
rubygems_version: 1.8.24
|