140 Commits

Author SHA1 Message Date
Casey Foster
74ae40ea72 Fix #1915 - parse ordering in update 2012-12-13 12:56:11 -08:00
Jeremy Ashkenas
daf6892d22 Fixes #1912 -- Collection#fetch only parses once. 2012-12-13 13:54:59 -05:00
Jeremy Ashkenas
7e7b214269 revised update implementation with inline id/cid map instead of using an inline Collection for speed. Plus tests. 2012-12-11 17:10:02 -05:00
Jeremy Ashkenas
1191640d84 Fixes #1363, fixes #1461, removes View#dispose, adds Events#listenTo and Events#stopListening, and implements View#remove in terms of those. 2012-12-11 13:41:39 -05:00
Jeremy Ashkenas
d04c6182ef merged 2012-12-11 11:36:23 -05:00
Casey Foster
b9d0f8de44 #1894 sort option for add 2012-12-11 08:30:28 -08:00
Jeremy Ashkenas
a97880cb27 merged 2012-12-11 11:24:07 -05:00
Jeremy Ashkenas
5cab60be4f Defaulting remove:true for Collection#update 2012-12-11 11:20:19 -05:00
Brad Dunbar
6c0cda6707 Fix #1894, Collection#push should not sort. 2012-12-11 10:19:36 -05:00
Casey Foster
f71004fc7a Add failing test case for different idAttribute fields 2012-12-10 21:28:12 -08:00
Jeremy Ashkenas
a645760286 Change Collection#sort's event from 'reset' to 'sort', so you can optimize further if you wish. 2012-12-10 23:48:25 -05:00
Jeremy Ashkenas
104e9baebb Merging in Collection#update -- revised implementation, some tweaks: models are retained by default, there's no new 'update' event. 2012-12-10 15:59:23 -05:00
Casey Foster
bee1296053 Update update to merge cleanly 2012-12-08 17:55:15 -08:00
Casey Foster
c51b9cc5fd Rebasing update
Reuse prepared model in Collection#update

Remove extra whitespace

Trigger `update` after Collection#update unless silent

Don't create new models in Collection#update

Remove `slice` call from Collection#update

It isn't necessary since the array isn't being modified. `add` and
`remove` both slice the arrays they are passed, so simply reading
and passing on the pristine array to those functions is harmless.

Simplify excessive ternary in Collection#update

`update` supports simple add/remove/merge options

Cleanup `update`, support for any combination of add/merge/remove

Save a potentially useless `slice` in `update`

Add comments and more tests for Collection#update

Avoid splice and slice, they're too slow!
2012-12-08 17:48:55 -08:00
Jeremy Ashkenas
62b80bfc32 Fixes #1340 -- reset events include previous list of models, for added convenience. 2012-12-07 16:20:24 -05:00
Jeremy Ashkenas
23cc302a51 Fixes #1477 -- Changing Backbone's internal logic so that validation always happens, even when silent: true. Defining a validate should never allow state to become invalid, even during a silent change. 2012-12-06 16:48:29 -05:00
Casey Foster
aefd78f949 Merge branch 'master' into collection-update
Conflicts:
	test/collection.js
2012-12-05 10:31:31 -08:00
Jeremy Ashkenas
a7be84ef37 merged. 2012-12-04 17:41:57 -05:00
Casey Foster
beffc15a0b Add Collection#update to better use collection events 2012-12-01 12:26:11 -08:00
Brad Dunbar
0b2225655b Tweak sort test a bit. 2012-12-01 07:46:01 -05:00
Casey Foster
59850645e6 Only sort on add when it make sense 2012-11-30 15:40:01 -08:00
Tim Griesser
e5a3b0bba0 consistent 'parse' option on collection constructor & reset 2012-11-30 11:47:01 -05:00
Jeremy Ashkenas
942c19926d Merge pull request #1717 from davidgtonge/master
Stop Backbone throwing an error when an invalid model is added
2012-11-28 12:07:59 -08:00
Jeremy Ashkenas
a0aabb405b Revert "Fixes #1843 -- reworks parsing behavior. It now always applies if you define it, and no longer passes xhr. (parsing should be a pure function of the data)"
This reverts commit fbbb2e675e.
2012-11-28 14:39:01 -05:00
Jeremy Ashkenas
fbbb2e675e Fixes #1843 -- reworks parsing behavior. It now always applies if you define it, and no longer passes xhr. (parsing should be a pure function of the data) 2012-11-28 14:26:49 -05:00
Brad Dunbar
c9585a35ca Add a more meaningfull test for parsing by default. 2012-10-23 08:34:23 -04:00
Brad Dunbar
9b6826929c Tweak add implementation. 2012-10-08 10:14:53 -04:00
Dave Tonge
c2261bf962 Modified two tests to listen for error events rather than catching exceptions when adding an invalid model to a collection 2012-10-08 05:26:55 +01:00
Casey Foster
1e87356815 Added test for sorting during collection#add 2012-09-22 16:14:11 -07:00
Brad Dunbar
142d2ac832 Fix #1604 - Refactor add, remove index option.
* Avoid temporary constructs by splicing duplicates during traversal.
* Remove `index` option.
* Avoid creating empty options.
2012-09-22 08:59:37 -04:00
Brad Dunbar
c344201f6e Fix #1655 - sortBy & groupBy use attributes. 2012-09-17 11:31:46 -04:00
Brad Dunbar
85fca58bb9 Refactor reset/sort.
* Avoid creating unnecessary objects/arrays.
* Add test for sort-style comparator context.
2012-09-14 08:13:33 -04:00
Brad Dunbar
36a733a8bc Tweak string comparator implementation. 2012-09-14 08:05:41 -04:00
Brad Dunbar
8fdcaf207a Merge pull request #1587 from krawaller/master.
Conflicts:
	test/collection.js
2012-09-14 07:19:57 -04:00
KungD
8f29954011 removed prefix logic 2012-09-14 07:22:22 +02:00
KungD
4707b02056 removed automatic sorting in anticipation of sort option to .set 2012-09-12 18:27:10 +02:00
KungD
d2b4c1e55e test update 2012-09-12 07:06:54 +02:00
KungD
342a525e12 automatic resort when sorting attribute changes 2012-09-12 06:43:55 +02:00
Brad Dunbar
33cdab412e Drop doubled test prefixes. 2012-09-05 08:52:27 -04:00
Brad Dunbar
8ef1730b73 Consolidate test boilerplate; use consistent names. 2012-08-31 11:39:34 -04:00
Brad Dunbar
65ed49bbaa Clean up.
* Remove accidental globals.
* Add missing semicolon.
* Clean up test.
2012-08-31 08:51:09 -04:00
Brad Dunbar
1f3f45252f Consolidate sync/error events in Backbone.sync. 2012-08-29 16:14:48 -04:00
KungD
8fafad1208 changed suffix syntax to prefix 2012-08-28 21:21:58 +02:00
KungD
d97b88447d allowing propname arg as collection comparator 2012-08-26 18:38:16 +02:00
Irene Ros
330f2ba182 adding model parsing for collections on initialization of a collection from raw data 2012-08-16 17:13:02 -04:00
Brad Dunbar
c18b7763f8 Add a test and tweak whitespace for #1448. 2012-06-25 08:33:27 -04:00
Brad Dunbar
ff561ca206 Fix #1447 - model.save does not delete options.wait. 2012-06-25 07:39:48 -04:00
Brad Dunbar
4286e0c5ec Fix #1403 - Trigger "sync" unconditionally. 2012-06-16 10:45:01 -04:00
Brad Dunbar
4ecc161ecf Tweak tests a bit. 2012-06-15 11:30:49 -04:00
Casey Foster
f24ca5a0ed #1412 - Trigger "sync" event for fetch also 2012-06-15 07:33:38 -07:00