Commit c18448ee authored by Stephen Sawchuk's avatar Stephen Sawchuk

closes #584 - backbone_marionette footer issues.

parent ff32a65f
......@@ -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>
</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">
<li>
<a href="#">All</a>
......@@ -35,7 +37,9 @@
<a href="#completed">Completed</a>
</li>
</ul>
<button id="clear-completed"></button>
<button id="clear-completed" <% if (!completedCount) { %>class="hidden"<% } %>>
Clear completed (<%= completedCount %>)
</button>
</script>
<script type="text/html" id="template-header">
<h1>todos</h1>
......
......@@ -50,7 +50,7 @@ TodoMVC.module('Layout', function (Layout, App, Backbone) {
},
templateHelpers: {
activeCountLabel : function(){
activeCountLabel: function () {
return (this.activeCount === 1 ? 'item' : 'items') + ' left';
}
},
......@@ -59,25 +59,26 @@ TodoMVC.module('Layout', function (Layout, App, Backbone) {
this.listenTo(App.vent, 'todoList:filter', this.updateFilterSelection, this);
},
serializeData : function(){
serializeData: function () {
var active = this.collection.getActive().length;
var total = this.collection.length;
return {
activeCount : active,
totalCount : total,
completedCount : total - active
activeCount: active,
totalCount: total,
completedCount: total - active
};
},
onRender: function () {
this.$el.parent().toggle(this.collection.length > 0);
this.updateFilterSelection();
},
updateFilterSelection: function (filter) {
updateFilterSelection: function () {
this.ui.filters
.removeClass('selected')
.filter('[href="#' + filter + '"]')
.filter('[href="' + (location.hash || '#') + '"]')
.addClass('selected');
},
......
......@@ -94,7 +94,7 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $)
},
collectionEvents: {
'all' : 'update'
'all': 'update'
},
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