theironcook/Backbone.ModelBinder — pull request #124 by adamterlson (2013-04-19 04:23:38+00:00)
Title: Configurable attribute for element selector used in default bindings

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 do its property-name-based default binding.

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. :)