Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.
This repository was archived by the owner on May 29, 2019. It is now read-only.

Error in example from /devguide/templates.html#dom-bind #1275

Description

@tomalec

After copy'n'pasing example from https://www.polymer-project.org/1.0/docs/devguide/templates.html#dom-bind I get:

index.html:29 Uncaught TypeError: Cannot read property 'addEventListener' of null

I suspect it's because <template id="t" is="dom-repeat" items="{{data}}"> is not yet stamped from <template is="dom-bind">.

Activity

  1. tomalec commented on Jul 27, 2015

    @tomalec
    Author

    I posted a PR for it #1276
    As dom-change event works fine for root dom-bind element.

    I tried to make it work for nested templates but with no luck

    <body>
    
      <!-- Wrap elements with auto-binding template to -->
      <!-- allow use of Polymer bindings in main document -->
      <template is="dom-bind" id="r">
        List:
        <iron-ajax url="http://..." last-response="{{data}}"></iron-ajax>
    
        <template id="t" is="dom-repeat" items="{{data}}">
            <div>first:<span>{{item.first}}</span> last:<span>{{item.last}}</span></div>
        </template>
    
      </template>
    
    </body>
    <script>
      var r = document.querySelector('#r');
    
      // The dom-change event signifies when the template has stamped its DOM.
      r.addEventListener('dom-change', function() {
        // auto-binding template is ready.
        var t = document.querySelector('#t');
        console.log("Root dom-bind works!");
    
        // The dom-change event signifies when the template has stamped its DOM.
        t.addEventListener('dom-change', function() {
        // dom-repeat template is ready.
          console.log("Does nested dom-repeat work?");
        });
      });
    </script>

    Is there a way to do something like this?

  2. tomalec commented on Jul 28, 2015

    @tomalec
    Author

    Ok, above will work, once I will add auto attribute to <iron-ajax>:

    <iron-ajax url="/path/to/json/api" last-response="{{data}}" auto></iron-ajax>
  3. tomalec commented on Jul 30, 2015

    @tomalec
    Author

    Fixed by #1276

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions