Add placeHolder prop for EditableText

pull/1/head
Erik Johnston 2015-07-15 15:04:39 +01:00
parent dfd54f3b95
commit 2b81f46030
2 changed files with 12 additions and 2 deletions

View File

@ -43,14 +43,22 @@ module.exports = React.createClass({
},
onFinish: function(ev) {
if (ev.target.value) {
this.setValue(ev.target.value);
} else {
this.cancelEdit();
}
},
render: function() {
var editable_el;
if (this.state.phase == this.Phases.Display) {
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>

View File

@ -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',
};
},