tastejs/todomvc — pull request #573 by stephenplusplus (2013-05-27 03:35:31+00:00)
Title: backbone_marionette_require code style.

(#572)

I went through the Backbone + Marionette + Require app, and...

- Updated the code style
- Added in missing spec features:
- cancel edit on escape
- save edit on blur
- cursor at end of input on dblclick
- "Clear completed" button was always showing, and without a "(3)" counter
- grammar: 0 items left, 1 item left, 2 items left
- Switched all but one dependency to Bower
- [requirejs-tpl](https://github.com/ZeeAgency/requirejs-tpl) isn't registered
- Removed .jshintignore as most files are now out of the `lib` folder, and in the `bower_components` directory
- Consolidated to one index.html file. There were two index files. index-dev for non-compiled, index for a script that ran through the RequireJS optimizer. I thought it would be better if there was only one index.html, which, like all the other examples, serves non-uglified code. I kept the optimizer build file in, and removed the out of date build files
- Assigned `app` to `window.app` to make use of `app.vent`
- Previously, the `Footer` was being created and configured before an `app` module was accessible. By putting `app` in the global scope, I was able to use the `app.vent` method from within `js/views/Footer.js` without requiring access to the `app` module

I have a question to anyone more familiar with these tools. In `js/views/CompletedCount.js`:

```js
/*global define */

define([
'marionette',
'jquery'
], function (Marionette, $) {
'use strict';

return Marionette.View.extend({
initialize: function () {
this.listenTo(this.collection, 'all', this.render, this);
},

render: function () {
/**
*
* Can anyone recommend a better way of having this M.View
* represent just one element from a region?
*
* I tried setting an `el` property on the View to `#clear-completed`,
* but it didn't end up returning an element.
*
*/
this.$el = $('#clear-completed');

var completedTodos = this.collection.getCompleted();

this.$el
.toggle(completedTodos.length > 0)
.html('Clear completed (' + completedTodos.length + ')');
}
});
});
```

@jsoverson, as you were the original author of this app, would you mind giving a quick look over the changes, making sure this is still a good representation of Marionette with RequireJS?

And to everyone, if you can think of more ideal solutions than the ones I've implemented, please let me know.

Thanks!