Add placeHolder prop for EditableText
parent
dfd54f3b95
commit
2b81f46030
|
@ -43,14 +43,22 @@ module.exports = React.createClass({
|
|||
},
|
||||
|
||||
onFinish: function(ev) {
|
||||
this.setValue(ev.target.value);
|
||||
if (ev.target.value) {
|
||||
this.setValue(ev.target.value);
|
||||
} else {
|
||||
this.cancelEdit();
|
||||
}
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var editable_el;
|
||||
|
||||
if (this.state.phase == this.Phases.Display) {
|
||||
editable_el = <div ref="display_div" onClick={this.onClickDiv}>{this.state.value}</div>;
|
||||
if (this.state.value) {
|
||||
editable_el = <div ref="display_div" onClick={this.onClickDiv}>{this.state.value}</div>;
|
||||
} else {
|
||||
editable_el = <div ref="display_div" onClick={this.onClickDiv}><i>{this.props.placeHolder}</i></div>;
|
||||
}
|
||||
} else if (this.state.phase == this.Phases.Edit) {
|
||||
editable_el = (
|
||||
<div>
|
||||
|
|
|
@ -22,6 +22,7 @@ module.exports = {
|
|||
propTypes: {
|
||||
onValueChanged: React.PropTypes.func,
|
||||
initalValue: React.PropTypes.string,
|
||||
placeHolder: React.PropTypes.string,
|
||||
},
|
||||
|
||||
Phases: {
|
||||
|
@ -33,6 +34,7 @@ module.exports = {
|
|||
return {
|
||||
onValueChanged: function() {},
|
||||
initalValue: '',
|
||||
placeHolder: 'Click to set',
|
||||
};
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue