15: Toggle All Todos

Let's work toggle button to change all todo's completed status at once.

  1. Add toggleAllTodos invocation to controller element by x-invocations directive.
  2. Add click event listener to <input> of toggle-all by x-on:change directive. It calls toggleAllTodos invocation.

<body>
  <section class="todoapp"


      destroyTodo (_, payload, meta) {
        this.todos.splice(payload.index, 1)
      },
      toggleAllTodos (_, payload, meta) {
        this.todos.forEach(
          todo => todo.completed = meta._.$.checked
        )
      },
    }"

  ::>

    <section class="main">
      <input id="toggle-all" class="toggle-all" type="checkbox" @change="toggleAllTodos">
      <label for="toggle-all">Mark all as complete</label>

    </section>

  </section>
</body>
</html>