backbone.picky icon indicating copy to clipboard operation
backbone.picky copied to clipboard

Changed event parameters to always include collection; "diff" hash for MultiSelect

Open hashchange opened this issue 11 years ago • 0 comments

This PR provides additional info to event handlers.

SingleSelect events now pass the collection as the second parameter. The collection info is required by event handlers listening to more than one collection.

(That's a side effect of multi-collection support, #16 / #23. model.collection used to be enough, but it just gives access to the first collection a model is assigned to.)

MultiSelect select:* events provide a "diff" hash, {selected: [...], deselected: [...]}, as the second parameter. The collection is now passed as the third parameter (used to be second).

The MultiSelect change could have been backward compatible by providing the diff as third parameter, keeping the collection second. But then the API would have been inconsistent with SingleSelect (arg pattern: modification (model), context (collection), options). I reckon the break in compatibility is not a big deal, though, the args hadn't even been documented so far.

Based on my previous commits. Tests are adjusted, documentation updated.

hashchange avatar Jan 27 '14 09:01 hashchange