Re-using template of field and not getting value

#1

I’ve created 2 templates for fields I knew I would re-use in my little app, and now I have.

The original use of them in my first form works flawlessly and I’m able to get my values out of them, and fill the value in them if it’s known.

Templates below:

<template name="callLocation">
    {{#if $eq modeCallSheet "NewCall"}}
        {{> inputAutocomplete settings=settings id="callLocation"}}
        <label for="callLocation">Location</label>
    {{else}}
        {{> inputAutocomplete settings=settings callInfoLocation=callInfoLocation id="callLocation"}}
        <label for="callLocation">Location</label>
    {{/if}}
</template>

and

<template name="latAndLon">
    <input type="text" id="latAndLonInfo" class="latAndLonInfo" value="{{#if $eq callLocSet true}}{{callLatLon}}{{/if}}" />
    <label for="latAndLonInfo">Coordinates</label>
</template>

And their initial use is here:

<div class="row">
        <div class="col s12">
            <div class="row">
                <div class="input-field col s12 m6 l4">
                    {{> callLocation}}
               </div>
                <div class="input-field col s12 m6 l4">
                    {{> latAndLon}}
                </div>
            </div>
        </div>
    </div>

When interacting with the parent template above, i’m able to retrieve the values from both sub-templates with no issue.

I"ve re-used those 2 templates in another form, and in the new form it doesn’t work, and I get nothing (in the UI, nor the console) for the values when i try to get them with jQuery.

Here’s the code from the new parent template:

            <div class="row">
                <div class="input-field col s12 m12 l12">
                    {{> callLocation}}
                </div>
            </div>
            <div class="row">
                <div class="input-field col s12 m12 l12">
                    {{> latAndLon}}
                </div>
            </div>

Is there something to hierarchy of template placement in Blaze that I’m missing perhaps? I just figured I could call on these templates anytime.

In both cases for the .js file of the parent templates I use the following jquery to try and get the value of the fields:

    let callLocation = $("#callLocation").val();
    let latLon = $("#latAndLonInfo").val();

I appreciate any help,

#2

That’s really surprising. Maybe try using a regular text box field instead of inputAutocomplete first, and then you will probably discover that there’s a bug in inputAutocomplete with the settings you’re passing it.

#3

My second template for latAndLon is just a regular input field, and it’s the same story.

#4

Well then your $ function was overridden and something’s busted. Try document.querySelectorAll