theironcook/Backbone.ModelBinder — pull request #123 by adamterlson (2013-04-19 03:41:56+00:00)
Title: Configurable defaulting binding attribute for element selector

(Please ignore the jacked up commits, it's really just one--the second)

In working with model binder, it was unclear to me how to just use the default binding mechanism but change what attribute model binder looks at to bind based on convention.

I have since found after looking through the unit tests that you can do:
Backbone.ModelBinder.createDefaultBindings(someEl, 'attribute') but I find this unwieldy and not very clear.

This change extends off of options on the bind() call the ability to pass in a new attribute that the default bindings will look at.

The scenario this nicely solves is where you have two models (both with the same properties) expressed on the page where each has a set of radios. They cannot all have the same name (as that'll make all radios mutually exclusive, instead of for just that item), but they do all need to bind to the same property on their respective models.

I could see enhancing this further so that the entire selector is configurable, but I didn't want to be too greedy. :)