Notice: The Monaca & Onsen UI Community Forum is shutting down.

For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.

Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.

Getting null when accessing inner element from ons-template. Getting null when document.getElementById('infinite-list') is called from javascript



  • <ons-template id="home.html">
    [undefined](undefined)
        <ons-page>
          <ons-toolbar>
            <div class="left">
              <ons-toolbar-button onclick="fn.open()">
                <ons-icon icon="ion-navicon, material:md-menu"></ons-icon>
              </ons-toolbar-button>
                </div>
                <div class="center">
                  Main
                </div>
              </ons-toolbar>
              <ons-list>
                <ons-lazy-repeat id="infinite-list"></ons-lazy-repeat>
              </ons-list>
          </ons-page>
      </ons-template>
    

  • Onsen UI

    @raju That’s correct. It’s the way ons-template works. I’d recommend using native template element instead since it’s supported from v2.4.0 onwards.