Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
polymer-selector: add selectedIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiefu committed Nov 6, 2013
1 parent 0962d6c commit 1e7d62d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion polymer-selector/polymer-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<link rel="import" href="../polymer-selection/polymer-selection.html">

<polymer-element name="polymer-selector"
attributes="selected multi valueattr selectedClass selectedProperty selectedItem selectedModel notap target itemsSelector activateEvent">
attributes="selected multi valueattr selectedClass selectedProperty selectedItem selectedModel selectedIndex notap target itemsSelector activateEvent">
<template>
<polymer-selection id="selection" multi="{{multi}}" on-polymer-select="{{selectionSelect}}"></polymer-selection>
<content id="items" select="*"></content>
Expand Down Expand Up @@ -150,6 +150,14 @@
* @default null
*/
selectedModel: null,
/**
* In single selection, this returns the selected index.
*
* @attribute selectedIndex
* @type number
* @default -1
*/
selectedIndex: -1,
/**
* The target element that contains items. If this is not set
* polymer-selector is the container.
Expand Down Expand Up @@ -269,6 +277,8 @@
} else {
this.selectedModel = null;
}
this.selectedIndex = this.selectedItem ?
parseInt(this.valueToIndex(this.selected)) : -1;
},
valueToIndex: function(value) {
// find an item with value == value and return it's index
Expand Down

0 comments on commit 1e7d62d

Please sign in to comment.