93 Commits

Author SHA1 Message Date
Jeremy Ashkenas
4b4f2c1ad6 missed an API regression in model.changedAttributes(), reimplementing in the same way as the original. 2012-01-30 12:18:58 -05:00
Brad Dunbar
2a6624cb24 use _.has for Object proto props 2012-01-30 05:52:47 -05:00
Brad Dunbar
2f654d2676 cache changed attributes 2012-01-30 05:00:41 -05:00
Brad Dunbar
0d6e5f3934 Fire 'change:attr' from change 2012-01-27 14:07:33 -05:00
Jeremy Ashkenas
ab164c450d Overhauling 'validate' -- Receives the computed new state of the attrs, not just the delta. Now runs on model create, raising an exception if you try to 'new' and invalid model ... also runs even if changed silently. 2012-01-23 18:16:20 -05:00
Jeremy Ashkenas
36fde545f9 Merge pull request #872 from vovik/master
fixed typo in test for (presumably) equality
2012-01-22 10:04:57 -08:00
Brad Dunbar
3a891854e8 setting undefined attributes
* undefined attrs should still be set
* unset triggers change for undefined attrs
* values are set regardless of change/equality
2012-01-20 11:02:46 -05:00
vlad
c7c7b3c1a1 fixed typo in test for (presumably) equality 2012-01-18 13:49:09 -08:00
Brad Dunbar
b05deb5fb5 fix #871 - calling set with 'attributes' property 2012-01-18 12:45:09 -05:00
Brad Dunbar
397d11e340 equals is deprecated; use equal instead
http://docs.jquery.com/QUnit/equal#actualexpectedmessage
2012-01-17 23:52:12 -05:00
Jeremy Ashkenas
cea56e523a Fixes #563. Initial draft of 'wait: true' for pessimistic instead of optimistic save() create() and destroy(). Makes it easier to have your asynchronous UI and eat it too. 2012-01-17 15:26:26 -05:00
Jeremy Ashkenas
42d321f236 Fixes #570, supports Model#save(key, value) 2012-01-17 11:55:15 -05:00
Jeremy Ashkenas
34e0f7fb26 Fixes #582, fixes #425, run a second loop to trigger change:attribute events after all changes have been made. 2012-01-13 17:08:48 -05:00
Jeremy Ashkenas
4316b04ffa allow the passing of any number of arguments to Model#initialize 2012-01-13 16:10:14 -05:00
Jeremy Ashkenas
51335bf10f Fixes #641 -- on and off are now the preferred names for bind and unbind, following jQuery. 2012-01-13 15:27:57 -05:00
Jeremy Ashkenas
1d90bb9cfc binding the comparator function before using it, so that you can rely on properties of your collection within it. 2012-01-12 15:13:22 -05:00
Jeremy Ashkenas
6b3ff7b035 Fixes #9, Backbone comparators can now be either sort() or sortBy() iterators. 2012-01-06 14:53:43 -05:00
Jeremy Ashkenas
060da2b991 Merge pull request #842 from braddunbar/hasChanged-comparison
hasChanged/set should use the same comparison
2012-01-06 06:58:55 -08:00
Brad Dunbar
934aba4c6e hasChanged/set should use the same comparison
When setting a value, if hasChanged and set disagree
about equality then hasChanged will return true without
firing a 'changed:*' event (or vice versa).  Using the
same comparison (_.isEqual) solves this problem.
2012-01-06 09:19:23 -05:00
=
b4e650b98f A model's urlRoot can now be a function allowing definition at runtime. 2011-12-22 15:23:12 -10:00
Magnus Holm
bdbcfa9da2 parse:true runs the attributes through parse():
`new Model(attr, {parse:true})` will now call
Model.prototype.parse(attr). This is useful if
you want to create a model out of an object
structure from an external server.
2011-12-04 17:48:47 +01:00
Jeremy Ashkenas
6687cde196 merging in #739 -- a massive simplification. 2011-11-23 16:48:39 -05:00
Brad Dunbar
93ad86cfa9 add tests for #730 and #565 2011-11-10 13:45:27 -05:00
Brad Dunbar
66d209d4f9 unit test for ignore values when unsetting 2011-11-10 10:10:17 -05:00
Brad Dunbar
3f004196bd assert that change is only triggered once 2011-11-09 14:05:58 -05:00
Brad Dunbar
20a2e3408a set _changing = false only if !alreadyChanging 2011-11-09 13:56:43 -05:00
Tim Branyen
fbffb36819 Merge pull request #698 from alexgraul/master
Fix for Issue #690
2011-10-29 13:21:15 -07:00
Alex Graul
970ce0762c fix for wrapped errors inside success callbacks on save, issue #690 2011-10-29 15:51:41 -04:00
Irene Ros
2be771412b Setting _unsetAttributes to false in unset rather than changedAttributes so that the unset attributes aren't lost on subsequent calls of changedAttributes. Added test to verify this behavior. 2011-10-29 12:27:46 -04:00
Steve Mason
5310996d09 Test for unset attributes not being returned by changedAttributes 2011-08-11 08:55:12 +01:00
Chris Moore
3145b4db22 isNew should use id, not idAttribute 2011-07-25 17:48:09 -04:00
Jeremy Ashkenas
da6d0b90ca resolving merge conflict, removing old test. 2011-07-05 09:42:15 -04:00
Jeremy Ashkenas
fcbedad8cd Addinga a test case for #459 2011-07-05 09:00:12 -04:00
Gavin Huang
4e9037b018 Model is no longer considered to be new if its id is a falsey value 2011-06-23 16:09:41 +08:00
Gavin Huang
573c347553 Fix unit test for model.isNew() 2011-06-23 16:08:16 +08:00
Matt Smith
d3a0b64603 remove model_with helper from test 2011-05-31 09:31:04 -04:00
Jeremy Ashkenas
e01ad9dd5b Merging in #232. Allow destroy() to be called on non-persisted objects ... just in case. 2011-05-27 11:30:48 -04:00
Jeremy Ashkenas
9accf97e9e Issue #246 -- never fire nested change events for the same model. The top-level one will do. 2011-05-27 10:29:14 -04:00
Matt Smith
12e9d95b45 add helper method to cleanup isNew test 2011-03-03 17:40:26 -05:00
Matt Smith
4595b48ffb refine the isNew test 2011-03-03 17:35:09 -05:00
Matt Smith
8971361bdc split out test for positive and negative ids 2011-03-03 17:33:19 -05:00
Matt Smith
5ebd949c7f use hash literal directly
This will make it harder to forget to instantiate the model.
2011-03-03 17:20:38 -05:00
Matt Smith
13acb8a822 fix documentation and tests for negative ids
The documentation said that a model was considered new if it had a negative id.
The test had the right message, but failed to instantiate the model the for the second assertion, and the assertion was inverted.
2011-03-03 17:06:16 -05:00
Raimonds Simanovskis
5a89ed3272 destroy of non-persisted model should not call sync 2011-02-15 15:17:20 +02:00
Jeremy Ashkenas
4489d7f5f1 Merging in a test for Issue #204 2011-02-07 15:02:20 -05:00
Jeremy Ashkenas
b86d3f6afc Issue #209 ... unsetting a missing attribute should not fire a change event. 2011-02-07 14:16:31 -05:00
Jeremy Ashkenas
1a9404cfe8 Initial support for models with non-default id attribute names (MongoDB, CouchDB). Various tickets. 2011-02-07 13:59:52 -05:00
Jeremy Ashkenas
ec6842009c Merging in #167, unsetting 'id' 2011-02-07 10:34:42 -05:00
Jeremy Ashkenas
39cabb8ac8 Merge branch 'master' of github.com:documentcloud/backbone 2011-01-11 12:58:23 -05:00
Jeremy Ashkenas
289d4e0066 Model::escape() now coerces non-string (non-falsy) values to strings before escaping them. 2011-01-11 12:58:15 -05:00