4 votes
Accepted

How to use Sprig's "Load More" Recipe After Update

The problem is that you are doing .relatedTo(category) but the variable you are passing is called relatedTo, not category. Just like with limit, based on your code, it should be .relatedTo(relatedTo). ...
user avatar
  • 7,200
3 votes
Accepted

Re-initialize / layout Masonry after a sprig change

This is oddly similar to this question. The problem is that your Sprig component includes the wrapper (the div with the masonry class), so reloading the Sprig component not only replaces the items, ...
user avatar
  • 6,795
3 votes
Accepted

Using Sprig's live search but show all entries first

Looking at the example from the Sprig Cookbook, it looks like the results container should live outside the sprig.isInclude: {% if sprig.isInclude %} <select sprig s-target="#results" ...
user avatar
3 votes
Accepted

How to use Sprig to filter categories using a dropdown

You need to apply the category filter to the entry query. {% set categoryId = categoryId ?? '' %} {% set entryQuery = craft.entries ({ search: search, section: 'articles', limit: 2, ...
user avatar
  • 6,326
3 votes

Simplifying code using the new andRelatedTo param

That's a lot of code to post in a question! The basic gist is that instead of merging new related params with relatedParams|merge and then applying to the query, you can call andRelatedTo(newParams) ...
user avatar
  • 6,326
2 votes
Accepted

Sprig - Filter entries by custom field checkbox values, separate values as well as all values

My suggestion would be to give the Select All Values checkbox a unique name. That way, you can easily detect whether it was selected or not. You should also break dropdown_field out into 2 variables ...
user avatar
  • 6,326
2 votes
Accepted

Show matrix fields based on quantity [Sprig]

The problem that you expect your qty variable to be an array of guests and initialize it like that, but once you set a quantity it will be an integer, so the loop won't work correctly. See this line: {...
user avatar
  • 6,795
2 votes
Accepted

How to filter entries by checkboxes using Sprig

I ended up using the following code - I just didn't come up with it earlier. I had to index the newsCat array used to denominate the single checkbox names. {% set newsCat = newsCat ?? '' %} {% set ...
user avatar
2 votes

How to filter entries by checkboxes using Sprig

Checkbox input field names should be in array format (not specific to Sprig), so I expect this should work. <input sprig type="checkbox" class="filter_checkbox" name="...
user avatar
  • 6,326
2 votes
Accepted

Sprig "Load more" not loading over https

Sprig will use whatever your site's base URL is set to, to construct the action URL. Ensure in Settings → Sites that the base URL is either set to an absolute path starting with https://, or if an ...
user avatar
  • 6,326
2 votes
Accepted

Sprig/Snaptcha CSRF issue/question

From your code sample it looks like you may be using Blitz to cache the page, in which case this is likely neither a Sprig issue nor a Snaptcha issue. A CSRF token is a dynamic token which should not ...
user avatar
  • 6,326
2 votes
Accepted

Sort entries by separate related entries count

I already responded to your question in a GitHub issue, but here we go again. Once you execute the tuitionLessonsQuery query, you can sort the resulting entries using the multisort filter, before ...
user avatar
  • 6,326
2 votes
Accepted

Sprig replacing search field even with s-preserve="true"

Why doesn't s-preserve work? Where have I gone wrong? Your question is very vague, but I'll try to answer as best I can. The s-preserve attribute (see https://htmx.org/attributes/hx-preserve/) will ...
user avatar
  • 6,326
2 votes
Accepted

Sprig use category filtering AND load more

Because of your component's element structure this is slightly more complex. I just added a new recipe to the Sprig cookbook called "Load More Complex" which should provide you with the ...
user avatar
  • 6,326
1 vote
Accepted

Sprig resets value on render

You can maintain state within your component either by using a hidden input field: {{ hiddenInput('count', count) }} Or by adding another s-val attribute to each button. <button sprig s-val:count=&...
user avatar
  • 6,326
1 vote

Hiding categories in real time with Sprig in a faceted search

If I understand you correctly, you're looking to build a faceted search, right? So the available filters (checkboxes in this case) are reduced based on the currently active filters to only show those ...
user avatar
  • 6,795
1 vote
Accepted

Swiper breaks when using Sprig

Do you get any error messages in the console? This will tell you what's going wrong with Swiper internally. Educated guess: Swiper probably stores some state with references to existing DOM nodes / ...
user avatar
  • 6,795
1 vote
Accepted

Using sprig for category filter but keep getting deprecation errors

Turns out the error was elsewhere in the template where I had forgotten to add the .all() statement. The code in the example is error free.
user avatar
1 vote

Using sprig for category filter but keep getting deprecation errors

One thing that stands out is that you're checking myQuery | length instead of items | length. Though I've tested it and this doesn't actually cause a deprecation error in my setup. Have you tried ...
user avatar
  • 6,795
1 vote
Accepted

Load currentUser using Sprig with Blitz

Duplicate of https://github.com/putyourlightson/craft-sprig/issues/118 The code is correct and what you are experiencing is likely due to local browser caching.
user avatar
  • 6,326

Only top scored, non community-wiki answers of a minimum length are eligible