Answers.Body: <p>Looking at the example from the <a href="https://putyourlightson.com/sprig-cookbook#search" rel="nofollow noreferrer">Sprig Cookbook</a>, it looks like the results container should live outside the <code>sprig.isInclude</code>:</p>
  <pre><code>{% if sprig.isInclude %}
      &lt;select sprig s-target=&quot;#results&quot; name=&quot;verdict&quot; id=&quot;verdict&quot;&gt;
          {# loop through options #}
      &lt;/select&gt;
      &lt;select sprig s-target=&quot;#results&quot; name=&quot;rating&quot; id=&quot;rating&quot;&gt;
          {# loop through options #}
      &lt;/select&gt;
      &lt;select sprig s-target=&quot;#results&quot; name=&quot;platform&quot; id=&quot;platform&quot;&gt;
          {# loop through options #}
      &lt;/select&gt;
      &lt;input sprig s-trigger=&quot;keyup changed&quot; s-target=&quot;#results&quot; type=&quot;search&quot; name=&quot;title&quot; id=&quot;title&quot; /&gt;
  {% endif %}
  
  &lt;div id=&quot;results&quot;&gt;
  {% if queryParams %}
      {% set entries = craft.entries(queryParams).orderBy('score').all() %}
      {% for entry in entries %}
          {{ entry.title }}
      {% endfor %}
  {% else %}
      {% set entries = craft.entries.section('games').orderBy('title').all() %}
      {% for entry in entries %}
          {{ entry.title }}
      {% endfor %}
  {% endif %}
  &lt;/div&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-14T07:18:59.860Z
Answers.Text: Thank you, that was it. Can't believe I didn't try that before.
Answers.UserDisplayName: darylknight
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-17T06:31:36.803Z
Answers.Text: Updated the answer to use the new `sprig.isInclude` syntax as of beta 15.
Answers.UserDisplayName: Ben Croker
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-14T03:51:11.947Z
Answers.LastActivityDate: 2020-09-17T06:31:14.193Z
Answers.LastEditDate: 2020-09-17T06:31:14.193Z
Answers.UserDisplayName: raptureaid
Body: <p>I want to display all results in the games section to start with, then once you search, it shows the filtered results. Sprig's starting point I think assumes that you're showing nothing, like a normal search box.</p>
  <p>With the code below, it shows all results to start with - but once there's a search query, it shows the filtered results, then also ALL of the results underneath those. What do I need to change to show all results first and REPLACE them with the filtered results after searching?</p>
  <p>It's something to do with the s-target stuff I think. The original loop gets 'moved' into #results when you search, but as I don't understand how Sprig works so I don't really know why it's doing it</p>
  <pre><code>{% set queryParams = {} %}
  {% set relatedParams = ['and'] %}
  
  {# This is where the query logic is -combining category filters and text search etc #}
  
  {% if sprig.include %}
      &lt;select sprig s-target=&quot;#results&quot; name=&quot;verdict&quot; id=&quot;verdict&quot;&gt;
          {# loop through options #}
      &lt;/select&gt;
      &lt;select sprig s-target=&quot;#results&quot; name=&quot;rating&quot; id=&quot;rating&quot;&gt;
          {# loop through options #}
      &lt;/select&gt;
      &lt;select sprig s-target=&quot;#results&quot; name=&quot;platform&quot; id=&quot;platform&quot;&gt;
          {# loop through options #}
      &lt;/select&gt;
      &lt;input sprig s-trigger=&quot;keyup changed&quot; s-target=&quot;#results&quot; type=&quot;search&quot; name=&quot;title&quot; id=&quot;title&quot; /&gt;
      &lt;div id=&quot;results&quot;&gt;&lt;/div&gt;
  {% endif %}
  
  {% if queryParams %}
      {% set entries = craft.entries(queryParams).orderBy('score').all() %}
      {% for entry in entries %}
          {{ entry.title }}
      {% endfor %}
  {% else %}
      {% set entries = craft.entries.section('games').orderBy('title').all() %}
      {% for entry in entries %}
          {{ entry.title }}
      {% endfor %}
  {% endif %}
  </code></pre>
  
Tags: <plugin-sprig>
Title: Using Sprig's live search but show all entries first
ThreadText: # Using Sprig's live search but show all entries first
  
  (Asked by: username_0 on 2020-09-13)
  
  I want to display all results in the games section to start with, then once you search, it shows the filtered results. Sprig's starting point I think assumes that you're showing nothing, like a normal search box.
  
  With the code below, it shows all results to start with - but once there's a search query, it shows the filtered results, then also ALL of the results underneath those. What do I need to change to show all results first and REPLACE them with the filtered results after searching?
  
  It's something to do with the s-target stuff I think. The original loop gets 'moved' into #results when you search, but as I don't understand how Sprig works so I don't really know why it's doing it
  
  ```
  {% set queryParams = {} %}
  {% set relatedParams = ['and'] %}
  
  {# This is where the query logic is -combining category filters and text search etc #}
  
  {% if sprig.include %}
      <select sprig s-target="#results" name="verdict" id="verdict">
          {# loop through options #}
      </select>
      <select sprig s-target="#results" name="rating" id="rating">
          {# loop through options #}
      </select>
      <select sprig s-target="#results" name="platform" id="platform">
          {# loop through options #}
      </select>
      <input sprig s-trigger="keyup changed" s-target="#results" type="search" name="title" id="title" />
      <div id="results"></div>
  {% endif %}
  
  {% if queryParams %}
      {% set entries = craft.entries(queryParams).orderBy('score').all() %}
      {% for entry in entries %}
          {{ entry.title }}
      {% endfor %}
  {% else %}
      {% set entries = craft.entries.section('games').orderBy('title').all() %}
      {% for entry in entries %}
          {{ entry.title }}
      {% endfor %}
  {% endif %}
  
  ```
  
  **Tags:** plugin-sprig
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-09-14. Score: 3 | Accepted answer
  
  Looking at the example from the [Sprig Cookbook](https://putyourlightson.com/sprig-cookbook#search), it looks like the results container should live outside the `sprig.isInclude`:
  
  ```
  {% if sprig.isInclude %}
      <select sprig s-target="#results" name="verdict" id="verdict">
          {# loop through options #}
      </select>
      <select sprig s-target="#results" name="rating" id="rating">
          {# loop through options #}
      </select>
      <select sprig s-target="#results" name="platform" id="platform">
          {# loop through options #}
      </select>
      <input sprig s-trigger="keyup changed" s-target="#results" type="search" name="title" id="title" />
  {% endif %}
  
  <div id="results">
  {% if queryParams %}
      {% set entries = craft.entries(queryParams).orderBy('score').all() %}
      {% for entry in entries %}
          {{ entry.title }}
      {% endfor %}
  {% else %}
      {% set entries = craft.entries.section('games').orderBy('title').all() %}
      {% for entry in entries %}
          {{ entry.title }}
      {% endfor %}
  {% endif %}
  </div>
  
  ```
  
  > **Comments:**
  > **username_0**: Thank you, that was it. Can't believe I didn't try that before.  
  > **username_2**: Updated the answer to use the new `sprig.isInclude` syntax as of beta 15.  
  
  ---
  
  