derickbailey/backbone.modelbinding — pull request #62 by tobowers (2012-02-07 14:38:55+00:00)
Title: Simple change to provide more flexibility for attributes

This is a simple change that could be the start of something larger. I had seen others talking about rails integration and the object[attr] names there. Rather than a major refactor, this small fix allowed me to monkey patch by overriding Configuration.getBindingValue as so:

```coffeescript
Backbone.ModelBinding.Configuration.prototype.getBindingValue = (element, type) ->
bindingAttr = this.getBindingAttr(type)
# looks for the railsish object[attribute] style
attributeRegex = /^[^\[]+\[(.+)\]$/
attributeValue = element.attr(bindingAttr)
if attributeRegex.test(attributeValue)
return attributeValue.match(attributeRegex)[1]
else
return attributeValue
```

To be clear: the above change is *not* in my commit - just changing where functions are assigned. It should save a little memory on every config instance too.