Commit c18448ee authored by Stephen Sawchuk's avatar Stephen Sawchuk

closes #584 - backbone_marionette footer issues.

parent ff32a65f
...@@ -23,7 +23,9 @@ ...@@ -23,7 +23,9 @@
<p>Further variations on the Backbone.Marionette app are also <a href="https://github.com/marionettejs/backbone.marionette/wiki/Projects-and-websites-using-marionette">available</a>.</p> <p>Further variations on the Backbone.Marionette app are also <a href="https://github.com/marionettejs/backbone.marionette/wiki/Projects-and-websites-using-marionette">available</a>.</p>
</footer> </footer>
<script type="text/html" id="template-footer"> <script type="text/html" id="template-footer">
<span id="todo-count"><strong></strong><span></span></span> <span id="todo-count">
<strong><%= activeCount %></strong> <%= activeCountLabel() %>
</span>
<ul id="filters"> <ul id="filters">
<li> <li>
<a href="#">All</a> <a href="#">All</a>
...@@ -35,7 +37,9 @@ ...@@ -35,7 +37,9 @@
<a href="#completed">Completed</a> <a href="#completed">Completed</a>
</li> </li>
</ul> </ul>
<button id="clear-completed"></button> <button id="clear-completed" <% if (!completedCount) { %>class="hidden"<% } %>>
Clear completed (<%= completedCount %>)
</button>
</script> </script>
<script type="text/html" id="template-header"> <script type="text/html" id="template-header">
<h1>todos</h1> <h1>todos</h1>
......
...@@ -50,7 +50,7 @@ TodoMVC.module('Layout', function (Layout, App, Backbone) { ...@@ -50,7 +50,7 @@ TodoMVC.module('Layout', function (Layout, App, Backbone) {
}, },
templateHelpers: { templateHelpers: {
activeCountLabel : function(){ activeCountLabel: function () {
return (this.activeCount === 1 ? 'item' : 'items') + ' left'; return (this.activeCount === 1 ? 'item' : 'items') + ' left';
} }
}, },
...@@ -59,25 +59,26 @@ TodoMVC.module('Layout', function (Layout, App, Backbone) { ...@@ -59,25 +59,26 @@ TodoMVC.module('Layout', function (Layout, App, Backbone) {
this.listenTo(App.vent, 'todoList:filter', this.updateFilterSelection, this); this.listenTo(App.vent, 'todoList:filter', this.updateFilterSelection, this);
}, },
serializeData : function(){ serializeData: function () {
var active = this.collection.getActive().length; var active = this.collection.getActive().length;
var total = this.collection.length; var total = this.collection.length;
return { return {
activeCount : active, activeCount: active,
totalCount : total, totalCount: total,
completedCount : total - active completedCount: total - active
}; };
}, },
onRender: function () { onRender: function () {
this.$el.parent().toggle(this.collection.length > 0); this.$el.parent().toggle(this.collection.length > 0);
this.updateFilterSelection();
}, },
updateFilterSelection: function (filter) { updateFilterSelection: function () {
this.ui.filters this.ui.filters
.removeClass('selected') .removeClass('selected')
.filter('[href="#' + filter + '"]') .filter('[href="' + (location.hash || '#') + '"]')
.addClass('selected'); .addClass('selected');
}, },
......
...@@ -94,7 +94,7 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $) ...@@ -94,7 +94,7 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $)
}, },
collectionEvents: { collectionEvents: {
'all' : 'update' 'all': 'update'
}, },
onRender: function () { onRender: function () {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment