Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormView has problems re-rendering select options because this.stickit() #176

Closed
mandragorn opened this issue Jan 12, 2016 · 1 comment · Fixed by #281
Closed

FormView has problems re-rendering select options because this.stickit() #176

mandragorn opened this issue Jan 12, 2016 · 1 comment · Fixed by #281

Comments

@mandragorn
Copy link
Contributor

For some reason it matches up whitespace text nodes as the current node with option nodes as the new node during hotswap causing it to generate mis-matched option list:

First render is ok:

    <select class="visit-type__select-service-type" name="serviceType" data-model="serviceType" data-feedback="serviceType" id="service-type" aria-label="Select service type">






    <option value="defaultOption">Select Service</option><option value="CT Scan">CT Scan</option><option value="Diagnostic Mammogram">Diagnostic Mammogram</option><option value="Infectious Disease">Infectious Disease</option><option value="MRI">MRI</option><option value="Screening Mammogram">Screening Mammogram</option></select>
    <select class="visit-type__select-visit-type visit-type__select-service-type--disabled" name="visitType" data-model="visitType" data-feedback="visitType" id="visit-type" aria-label="Select Visit Type" disabled="">

    <option value="defaultOption">Select Visit Type (optional)</option></select>

Template generated for 2nd render is ok:

    <select class="visit-type__select-service-type"
            name="serviceType" data-model="serviceType" data-feedback="serviceType" name="service-type" id="service-type" 
            aria-label="Select service type">
      <option value="defaultOption">
        Select Service
      </option>
        <option value="CT Scan">
          CT Scan
        </option>
        <option value="Diagnostic Mammogram">
          Diagnostic Mammogram
        </option>
        <option value="Infectious Disease">
          Infectious Disease
        </option>
        <option value="MRI">
          MRI
        </option>
        <option value="Screening Mammogram">
          Screening Mammogram
        </option>
    </select>

But after template renderer merges, they are not ok:

    <select class="visit-type__select-service-type" name="serviceType" data-model="serviceType" data-feedback="serviceType" id="service-type" aria-label="Select service type">






    <option value="defaultOption">Select Service</option><option value="CT Scan">CT Scan</option><option value="Diagnostic Mammogram">Diagnostic Mammogram</option><option value="defaultOption">Infectious Disease</option><option value="Diagnostic Mammogram">MRI</option><option value="MRI">Screening Mammogram</option></select>
    <select class="visit-type__select-visit-type visit-type__select-service-type--disabled" name="visitType" data-model="visitType" data-feedback="visitType" id="visit-type" aria-label="Select Visit Type" disabled="">

    <option value="defaultOption">Select Visit Type (optional)</option></select>
@mandragorn
Copy link
Contributor Author

Workaround: Removing whitespace around the options seems to help:

Original:

    <select ...>
      <option value="{{defaultOptionValue}}">
        {{i18n "dropdown.default"}}
      </option>
      {{#each serviceTypes}}
        <option value="{{id}}">
          {{attributes.userFriendlyName}}
        </option>
      {{/each}}
    </select>

New:

    <select ...>
      <option value="{{defaultOptionValue}}">
        {{~i18n "dropdown.default"~}}
      </option>
      {{~#each serviceTypes~}}
        <option value="{{id}}">
          {{~attributes.userFriendlyName~}}
        </option>
      {{~/each~}}
    </select>

mandragorn pushed a commit to mandragorn/backbone-torso that referenced this issue Jan 14, 2016
…that when it is bound during delegate it does not screw up the DOM.
@kentmw kentmw changed the title Template renderer has problems when re-rendering select options FormView has problems re-rendering select options because this.stickit() Jan 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant