File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -13,16 +13,26 @@ module.exports = React.createClass({
1313 getInitialState : function ( ) {
1414 return { open : false }
1515 } ,
16+ handleItemClick : function ( item ) {
17+ this . setState ( {
18+ open : false ,
19+ itemTitle : item
20+ } ) ;
21+ } ,
1622 render : function ( ) {
1723 var list = this . props . items . map ( function ( item ) {
18- return < ListItem item = { item } />
19- } ) ;
24+ return < ListItem
25+ item = { item }
26+ whenItemClicked = { this . handleItemClick }
27+ className = { this . state . itemTitle === item ? "active" : "" }
28+ />
29+ } . bind ( this ) ) ;
2030
2131 return < div className = "dropdown" >
2232 < Button
2333 whenClicked = { this . handleClick }
2434 className = "btn-default"
25- title = { this . props . title }
35+ title = { this . state . itemTitle || this . props . title }
2636 subTitleClassName = "caret"
2737 />
2838 < ul className = { "dropdown-menu " + ( this . state . open ? "show" : "" ) } >
Original file line number Diff line number Diff line change 11var React = require ( 'react' ) ;
22
33module . exports = React . createClass ( {
4+ handleClick : function ( ) {
5+ this . props . whenItemClicked ( this . props . item ) ;
6+ } ,
47 render : function ( ) {
5- return < li > < a > { this . props . item } </ a > </ li >
8+ return < li className = { this . props . className } >
9+ < a onClick = { this . handleClick } > { this . props . item } </ a >
10+ </ li >
611 }
712} ) ;
You can’t perform that action at this time.
0 commit comments