documentcloud/backbone — pull request #2016 by evotopic (2012-12-24 14:50:42+00:00)
Title: Add possibility to manipulate input values before setting an attribute

This allows us to specify a 'tailor' method which receives the set attributes and manipulates their value according to some user defined rules. Think of the scenario where you want an attribute to have a numeric value between 0 and 1. If someone passes something more than 1, you force it to 1 and trigger a change only if the previous value is not also 1 (even if what you set is different than 1). Another case: make sure a name attribute is always capitalized, so setting 'john' will be stored as 'John'. After this if you set it like 'jOhN' it won't trigger the the change event since it is tailored to 'John'. Obviously there are lots of other scenarios on which this method proves to be useful.