PolymerElements / iron-selector

Manages a list of elements that can be selected
32 stars 55 forks source link

Fire event in items when they are selected/deselected #74

Closed reinert closed 8 years ago

reinert commented 8 years ago

It would be nice if, inside an item, we could be notified whenever it's selected and deselected. It would provide support to better encapsulation and code cohesion, since the user could register functions inside the polymer element to deal with the revealing/hiding of it.

My use case: each page of my app is a custom "page-element". Inside each page element of my app, I would like to execute some logic specific to each page, when the page is selected (revealed) and deselected (hid).

reinert commented 8 years ago

After some discussion in the g+ community, I think this feature is not necessary. The element already provide the iron-select event, with the item specified in the detail. This higher level event, enables us to develop a behavior composing the element to add the suggested feature.

I was wondering though, how could I manage to be notified before the element is rendered and after it. Also, if I could control if the element should be rendered or rollback to the previous element.

bicknellr commented 8 years ago

The iron-activate event is fired before selection occurs and can be cancelled to prevent the selection from occurring. iron-select is fired after the iron-selected class is toggled in _applySelection.