How to listen for changing of selected item in core-list-dart element

388 views
Skip to first unread message

ha...@dotdotcommadot.com

unread,
Jul 15, 2014, 11:23:40 AM7/15/14
to w...@dartlang.org
Hi guys,

Does anyone know how I can listen for changing of the selected item on a core-list-dart?

What I've tried is:
<core-list-dart id="list" data="{{albums}}" height="10" >
   
<template>
       
<div class="{{ {item: true, selected: selected} }}">
       
<div class="title">{{title}}</div>
       
</div>
   
</template>
</core-list-dart>

@override
ready
()
{
    albums
.addAll(new AlbumDelegate().getAlbums());
       
    list
= shadowRoot.querySelector("#list");
   
//(list.selection as CoreSelection).onSelect.listen((_) => handleAlbumListChange());
   
//list.selectedHandler = handleAlbumListChange;
}


But none of this works obviously.
There doesn't seem to be an 'onSelectionChanged' stream or anything similar.
Am I overlooking something?

Thanks in advance!
Hans

Hans - Jürgen Alps

unread,
Jul 15, 2014, 12:40:04 PM7/15/14
to w...@dartlang.org

The core-list element supports the core-activated event. The event detail contains the activated/selected element. You should declare the listen with list.on ['core-activated'].listen(handleAlbumListChange)
Best Regals
Hans

--
You received this message because you are subscribed to the Google Groups "Dart Web Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web+uns...@dartlang.org.
Visit this group at http://groups.google.com/a/dartlang.org/group/web/.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/web/153ac471-1b9c-46b3-bc32-f0e632009061%40dartlang.org.

Günter Zöchbauer

unread,
Jul 15, 2014, 4:55:12 PM7/15/14
to w...@dartlang.org, hansjuer...@googlemail.com
I had troubles getting event.details (which is often used in core/paper-elements events) because it was always `null` and got
I haven't had a closer look myself yet but might be helpful here too.

ha...@dotdotcommadot.com

unread,
Jul 23, 2014, 10:37:33 AM7/23/14
to w...@dartlang.org, ha...@dotdotcommadot.com
Thanks guys.

Hans, your solution was almost right :).
It should've been " list.on ['core-activate'].listen(handleAlbumListChange)".

So, ''core-activate' instead of ''core-activated'.

Oh, the joys of not having code-hinting...

ha...@dotdotcommadot.com

unread,
Jul 23, 2014, 10:39:47 AM7/23/14
to w...@dartlang.org, ha...@dotdotcommadot.com
If it's going to stay "the interop way", perhaps we should make these event names constants instead of random strings?
This way people can get at lost some code hinting..right?


On Tuesday, July 15, 2014 5:23:40 PM UTC+2, ha...@dotdotcommadot.com wrote:

Günter Zöchbauer

unread,
Jul 23, 2014, 11:10:04 AM7/23/14
to w...@dartlang.org, ha...@dotdotcommadot.com
I would prefer getters like I did here when porting polymer-elements manually

Günter Zöchbauer

unread,
Jul 23, 2014, 11:11:14 AM7/23/14
to w...@dartlang.org, ha...@dotdotcommadot.com
then you could use it like

list.onCoreActivate.listen(handleAlbumListChange)

ha...@dotdotcommadot.com

unread,
Jul 24, 2014, 4:55:06 AM7/24/14
to w...@dartlang.org, ha...@dotdotcommadot.com
Yes, I completely agree with Gunter.


On Tuesday, July 15, 2014 5:23:40 PM UTC+2, ha...@dotdotcommadot.com wrote:

Günter Zöchbauer

unread,
Jul 24, 2014, 5:35:38 AM7/24/14
to w...@dartlang.org, ha...@dotdotcommadot.com
Reply all
Reply to author
Forward
0 new messages