Closed jakemac53 closed 8 years ago
lgtm
Do we still use var model = new DomRepeatModel.fromEvent(e) with on-click events. I'm getting the following error. `Uncaught Unhandled exception: type 'IronList' is not a subtype of type 'TemplateElement' in type cast.
interesting, can you post a repro?
I wonder if it's the iron-list I'm using:
<iron-list items="[[data]]" as="item">
<template>
<div class="cards">
<paper-card>
<div class="card-content" >
<div class="horizontal layout">
<div>
Date: <span style="font-weight: bold">[[formatDate(item.createdDate)]]</span>
</div>
<div style="padding-left: 20px">
Created By: <span style="font-weight: bold">[[item.createdBy]]</span>
</div>
</div>
<div>
<p>[[item.description]]</p>
</div>
</div>
<div class="card-actions">
<paper-icon-button icon="chrome-reader-mode" title="Details" on-click="onShutdownClicked"></paper-icon-button>
</div>
</paper-card>
</div>
</template>
</iron-list>
void onShutdownClicked(Event e, [_]){
var model = new DomRepeatModel.fromEvent(e);
set('selectedShutdownId', model.item['id']);
}```
It was working with rc.8.
Is it allowed to use DomRepeatModel
when not inside a dom-repeat
? I thought not.
@jakemac53 could it be because of this ? Chances are that removing the type it will work with iron-list
too ?
BTW @jakemac53 : probably index
too should be treated in a similar way of item
when using indexAs
.
Also what will happen when we have nested dom-repeat
? Would be nice to have all the item
s and index
es too, or a hierarchy of models...
Ya, it looks like you are using iron-list
not dom-repeat
, so that is the issue. It was working before only by accident. You could use probably use IronList.modelForElement
instead (with the event.target
)?
I tried
Element el = e.target as Element;
var model = ($['itemList'] as IronList).modelForElement(el);
print(model.index);
but keep getting the following error
Uncaught Unhandled exception: Class 'TemplateInstance' has no instance getter 'index'.
example shows:
/// Example:
///
/// var model = modelForElement(el);
/// if (model.index < 10) {
/// model.set('item.checked', true);
/// }
Found this and changed it to model.get('item.id') which worked. http://stackoverflow.com/questions/33640160/how-to-get-model-for-element-in-iron-list-polymer-dart
Thanks.
Fixes https://github.com/dart-lang/polymer-dart/issues/654