question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues with Chrome and Safari but not Firefox

See original GitHub issue

I have this code that works as expected in Firefox. A user uses a dropdown and the results populate subsequent text inputs. For example the s-val:desc fills in the text input desc that follows. In Chrome and Safari it does not work. Changing the dropdown does not populate and since they are required, the form fails.

<div class="col-2">
    <div id="sel" s-preserve="true">
      {% set cpt_options = craft.entries.section('cptCodes2').all() %}
      <select class="form-select">
        <option value="">
          Code
        </option>
        {% for option in cpt_options %}
          <option sprig s-val:cpt="{{ option.code }}"  s-val:desc="{{ option.description }}" s-val:price="{{ option.number_price }}" {{ option.id == cpt ? ' selected' }}>
            {{ option.title~' : '~option.description }}
          </option>
        {% endfor %}
</select>
    </div>
  </div>

  <div class="col-4">
    {{ input('text', 'fields[description]', desc, {
      class: 'form-control',
      required: true
      }) }}
  </div>
  <div class="col-2">
    <div class="input-group mb-3">
      <span class="input-group-text">$</span>
      {{ input('text', 'fields[billed]', price, {
        class: 'form-control',
        required: true
        }) }}
    </div>
  </div>

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
AbbeyDesigncommented, Oct 18, 2022

@mattstein unfortunately that’s not it.

0reactions
stevendierickcommented, Oct 18, 2022

As @bencroker said, s-val won’t work on option values. It’s weird that it works in Firefox, though. And as @mattstein said, you might need to add the name attribute to your <select>, as well as the sprig attribute.

Since you’re working with entries, you could refactor your code a bit and just query your cptCodes2 section by id of your cpt value, which will be the entry id, and get the needed information based off of that.

For example:

{% set cpt = cpt ?? null %}

{% set cpt_options = craft.entries.section('cptCodes2').all() %}

{% set get_option = cpt ? craft.entries.section('cptCodes2').id(cpt).one() : null %}
{% set desc = get_option.description ?? null %}
{% set price = get_option.number_price ?? null %}

<div class="col-2">
    <div id="sel" s-preserve="true">
        <select sprig name="cpt" class="form-select">
            <option value="">Code</option>
            {% for option in cpt_options %}
                <option value="{{ option.id }}"{{ option.id == cpt ? 'selected' }}>
                    {{ "#{option.title}: #{option.description}" }}
                </option>
            {% endfor %}
        </select>
    </div>
</div>

<div class="col-4">
    {{ input('text', 'fields[description]', desc, {
        class: 'form-control',
        required: true
    }) }}
</div>

<div class="col-2">
    <div class="input-group mb-3">
        <span class="input-group-text">$</span>
        {{ input('text', 'fields[billed]', price, {
            class: 'form-control',
            required: true
        }) }}
    </div>
</div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Firefox can't load websites but other browsers can
This article describes problems where Firefox cannot load websites but other Web browsers (such as Microsoft Edge or Internet ExplorerSafariEpiphany on ...
Read more >
If Safari on Mac doesn't open a webpage or isn't working as ...
If Safari isn't working as you expect, one of these solutions might help. These solutions are for issues that affect Safari on Mac,...
Read more >
Why can I browse with Firefox but not with Safari or Chrome?
Today I find myself able to browse with Firefox but not with Chrome or Safari. A select few pages are still working but...
Read more >
Website loads fine on Firefox, IE, Safari but not on Chrome
Website loads fine on Firefox, IE, Safari but not on Chrome · Disabling chrome extensions · Deleted cache on both devices · Reinstalled...
Read more >
How To Fix Web Browser Audio (Chrome, Safari, Firefox, Etc.)
Select the appropriate output device from the list. If the device(s) (microphone, headphones, speakers, audio interface, etc.) are not available, try ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found