Skip to content

Commit 0f96763

Browse files
christianesperaraddyosmani
authored andcommitted
Fix todo style by changing id to class (addyosmani#696)
1 parent 23e97f6 commit 0f96763

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

chapters/04-exercise-1.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,19 @@ We will be creating the application JavaScript files during the tutorial. Don't
6868
Now let's populate the body of index.html. We'll need an `<input>` for creating new todos, a `<ul id="todo-list" />` for listing the actual todos, and a footer where we can later insert statistics and links for performing operations such as clearing completed todos. We'll add the following markup immediately inside our body tag before the script elements:
6969

7070
```html
71-
<section id="todoapp">
72-
<header id="header">
71+
<section class="todoapp">
72+
<header class="header">
7373
<h1>todos</h1>
74-
<input id="new-todo" placeholder="What needs to be done?" autofocus>
74+
<input class="new-todo" placeholder="What needs to be done?" autofocus>
7575
</header>
76-
<section id="main">
77-
<input id="toggle-all" type="checkbox">
76+
<section class="main">
77+
<input class="toggle-all" type="checkbox">
7878
<label for="toggle-all">Mark all as complete</label>
79-
<ul id="todo-list"></ul>
79+
<ul class="todo-list"></ul>
8080
</section>
81-
<footer id="footer"></footer>
81+
<footer class="footer"></footer>
8282
</section>
83-
<div id="info">
83+
<div class="info">
8484
<p>Double-click to edit a todo</p>
8585
<p>Written by <a href="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/addyosmani">Addy Osmani</a></p>
8686
<p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
@@ -114,8 +114,8 @@ We also need to define the #stats-template template which we will use to populat
114114
<!-- index.html -->
115115

116116
<script type="text/template" id="stats-template">
117-
<span id="todo-count"><strong><%= remaining %></strong> <%= remaining === 1 ? 'item' : 'items' %> left</span>
118-
<ul id="filters">
117+
<span class="todo-count"><strong><%= remaining %></strong> <%= remaining === 1 ? 'item' : 'items' %> left</span>
118+
<ul class="filters">
119119
<li>
120120
<a class="selected" href="#/">All</a>
121121
</li>
@@ -127,7 +127,7 @@ We also need to define the #stats-template template which we will use to populat
127127
</li>
128128
</ul>
129129
<% if (completed) { %>
130-
<button id="clear-completed">Clear completed (<%= completed %>)</button>
130+
<button class="clear-completed">Clear completed (<%= completed %>)</button>
131131
<% } %>
132132
</script>
133133
```
@@ -254,18 +254,18 @@ To keep things short and simple, we won't be implementing all of the application
254254

255255
// Instead of generating a new element, bind to the existing skeleton of
256256
// the App already present in the HTML.
257-
el: '#todoapp',
257+
el: '.todoapp',
258258

259259
// Our template for the line of statistics at the bottom of the app.
260260
statsTemplate: _.template( $('#stats-template').html() ),
261261

262262
// At initialization we bind to the relevant events on the `Todos`
263263
// collection, when items are added or changed.
264264
initialize: function() {
265-
this.allCheckbox = this.$('#toggle-all')[0];
266-
this.$input = this.$('#new-todo');
267-
this.$footer = this.$('#footer');
268-
this.$main = this.$('#main');
265+
this.allCheckbox = this.$('.toggle-all')[0];
266+
this.$input = this.$('.new-todo');
267+
this.$footer = this.$('.footer');
268+
this.$main = this.$('.main');
269269

270270
this.listenTo(app.Todos, 'add', this.addOne);
271271
this.listenTo(app.Todos, 'reset', this.addAll);
@@ -275,12 +275,12 @@ To keep things short and simple, we won't be implementing all of the application
275275
// appending its element to the `<ul>`.
276276
addOne: function( todo ) {
277277
var view = new app.TodoView({ model: todo });
278-
$('#todo-list').append( view.render().el );
278+
$('.todo-list').append( view.render().el );
279279
},
280280

281281
// Add all items in the **Todos** collection at once.
282282
addAll: function() {
283-
this.$('#todo-list').html('');
283+
this.$('.todo-list').html('');
284284
app.Todos.each(this.addOne, this);
285285
}
286286

@@ -318,27 +318,27 @@ Now, let's add some more logic to complete our AppView!
318318

319319
// Instead of generating a new element, bind to the existing skeleton of
320320
// the App already present in the HTML.
321-
el: '#todoapp',
321+
el: '.todoapp',
322322

323323
// Our template for the line of statistics at the bottom of the app.
324324
statsTemplate: _.template( $('#stats-template').html() ),
325325

326326
// New
327327
// Delegated events for creating new items, and clearing completed ones.
328328
events: {
329-
'keypress #new-todo': 'createOnEnter',
330-
'click #clear-completed': 'clearCompleted',
331-
'click #toggle-all': 'toggleAllComplete'
329+
'keypress .new-todo': 'createOnEnter',
330+
'click .clear-completed': 'clearCompleted',
331+
'click .toggle-all': 'toggleAllComplete'
332332
},
333333

334334
// At initialization we bind to the relevant events on the `Todos`
335335
// collection, when items are added or changed. Kick things off by
336336
// loading any preexisting todos that might be saved in *localStorage*.
337337
initialize: function() {
338-
this.allCheckbox = this.$('#toggle-all')[0];
339-
this.$input = this.$('#new-todo');
340-
this.$footer = this.$('#footer');
341-
this.$main = this.$('#main');
338+
this.allCheckbox = this.$('.toggle-all')[0];
339+
this.$input = this.$('.new-todo');
340+
this.$footer = this.$('.footer');
341+
this.$main = this.$('.main');
342342

343343
this.listenTo(app.Todos, 'add', this.addOne);
344344
this.listenTo(app.Todos, 'reset', this.addAll);
@@ -367,7 +367,7 @@ Now, let's add some more logic to complete our AppView!
367367
remaining: remaining
368368
}));
369369

370-
this.$('#filters li a')
370+
this.$('.filters li a')
371371
.removeClass('selected')
372372
.filter('[href="#/' + ( app.TodoFilter || '' ) + '"]')
373373
.addClass('selected');
@@ -383,12 +383,12 @@ Now, let's add some more logic to complete our AppView!
383383
// appending its element to the `<ul>`.
384384
addOne: function( todo ) {
385385
var view = new app.TodoView({ model: todo });
386-
$('#todo-list').append( view.render().el );
386+
$('.todo-list').append( view.render().el );
387387
},
388388

389389
// Add all items in the **Todos** collection at once.
390390
addAll: function() {
391-
this.$('#todo-list').html('');
391+
this.$('.todo-list').html('');
392392
app.Todos.each(this.addOne, this);
393393
},
394394

0 commit comments

Comments
 (0)