Improve card handler

old
Javi Jimenez Villar 2015-08-01 09:00:48 +07:00
parent cc262911a5
commit 2da67943b8
2 changed files with 10 additions and 7 deletions

View File

@ -18,6 +18,7 @@ module.exports = React.createClass
getDefaultProps: ->
className : ''
loading : false
type : 'default'
getInitialState: ->
@ -45,7 +46,7 @@ module.exports = React.createClass
className += ' touch' if @props.onClick?
className += ' image' if @props.image?
className += ' color' if @props.color?
className += ' loading' if @state.loading?
className += ' loading' if @state.loading
style = {}
style.backgroundImage = "url(#{@props.image})" if @props.image?
style.backgroundColor = @props.color if @props.color
@ -66,4 +67,6 @@ module.exports = React.createClass
# -- Extends
loading: (value) ->
@setState loading: value
attributes = loading: value
attributes.ripple = undefined unless value
@setState attributes

View File

@ -17,8 +17,8 @@ module.exports = React.createClass
type : 'default'
# -- Events
onClick: (event, data) ->
@props.onClick? event, @, data
onClick: (event, data, index) ->
@props.onClick? event, item, @refs[index] if @refs[index]?
# -- Render
render: ->
@ -27,9 +27,9 @@ module.exports = React.createClass
<ul data-react-toolbox='list' className={className}>
{
for item, index in @props.dataSource
<li key={index} onClick={@onClick.bind null, item}>
{@props.itemFactory item}
for data, index in @props.dataSource
<li key={index} onClick={@onClick.bind null, data, index}>
{@props.itemFactory data, index}
</li>
}
</ul>