Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

HUGE_DICK_10_INCHES's avatar

Vue search filter checkbox issue

I have problem with checkboxes and vue filter of array.

https://jsfiddle.net/sky996/7d1kg5e4/3/

If you check first from array and search for any of others:

Check -> Learn javascript

Search -> Learn Vue

Vue appear to be checked..

Is that suppose to work like that?

How can I remove all from displayed list and append same time?

0 likes
1 reply
Yakagi's avatar

Hello,

You need to loop through the initial array and then filter it otherwise you'll re-render it every time and loose the checked input. You can do something like that :

<div id="app">
  <input type="text" v-model="search">
  <ol>
    <div v-for="todo in todos" :key="todo.text">
      <li v-show="todo.text.toLowerCase().includes(search.toLowerCase())">
        <label>
          <input type="checkbox">

          <del v-if="todo.done">
            {{ todo.text }}
          </del>
          <span v-else>
            {{ todo.text }}
          </span>
        </label>
      </li>
    </div>
  </ol>
</div>

Please or to participate in this conversation.