-1

I have a set of elements that have been generated dynamically through Handlebars as seen below

         {{#floor as |room i|}}
            <div class="btn-group-toggle" data-toggle="buttons" >
              <label class="btn btn-secondary" id="{{id}}">
                <input type="checkbox" autocomplete="off"> {{name}}
              </label>
            </div>
         {{/floor}}

As you can see, the elements are created with id="{{id}}". But when the page finishes loading, I want to hide these elements until a user clicks a button. I'm finding it hard to get the dynamic ids

Currently, I'm using JQuery as seen below

    $(document).ready(function () {
        $('#{{id}}').hide();
    });

this works with known ids, but not in this case where I don't know the id

SadCoder
  • 21
  • 4

1 Answers1

0

If you are trying to hide the element you can also select a unique class.

      {#floor as |room i|}}
        <div class="btn-group-toggle" data-toggle="buttons" >
          <label class="btn btn-secondary unique-class" id="{{id}}">
            <input type="checkbox" autocomplete="off"> {{name}}
          </label>
        </div>
     {{/floor}}

Using JQuery:

    $(document).ready(function () {
    $('.unique-class').hide();
});
FUZIION
  • 1,606
  • 1
  • 6
  • 19