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