derickbailey/backbone.marionette — pull request #185 by ifeins (2012-07-15 07:47:22+00:00)
Title: Organize ui elements

Now in views you can specify a "ui" hash that maps between ui element's names and their associated jQuery selectors:
* Implemented base functionality in View#bindUIElements method, and modified ItemView and CompositeView to invoke it.
* Added specs.
* Modified documentation.

I didn't implement this functionality for CollectionView since:
* CollectionView doesn't have a template of its own and so I thought it would make less sense to have this functionality.
* Also if I had implemented this functionality for CollectionView then this can turn problematic for CompositeView, since CompositeView#render calls CollectionView#render which will call bindUIElements and will try to create selectors for elements that may belong to the CompositeView template (and not to the collection), resulting in empty jQuery objects for those elements belonging to the CompositeView template.
It's possible to solve this by forcing a convention when defining ui elements in CompositeView like so:
ui:
foo: "..."
bar: "..."
collectionElements:
baz: "..."
But I thought that for simplicity sake it's best to leave it out.

This is enforced in the CompositeView spec to indicate this is by design and not a bug.