Upon exiting edit post modal, foucs is placed on the respective text input field

Этот коммит содержится в:
nickago
2015-08-21 09:45:48 -07:00
родитель ddcdcc3e2c
Коммит 794881ce24
3 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@@ -34,6 +34,7 @@ module.exports = React.createClass({
);
$("#edit_post").modal('hide');
$(this.state.refocusId).focus();
},
handleEditInput: function(editText) {
this.setState({ editText: editText });
@@ -52,12 +53,12 @@ module.exports = React.createClass({
var self = this;
$(this.refs.modal.getDOMNode()).on('hidden.bs.modal', function(e) {
self.setState({ editText: "", title: "", channel_id: "", post_id: "", comments: 0 });
self.setState({ editText: "", title: "", channel_id: "", post_id: "", comments: 0, refocusId: "" });
});
$(this.refs.modal.getDOMNode()).on('show.bs.modal', function(e) {
var button = e.relatedTarget;
self.setState({ editText: $(button).attr('data-message'), title: $(button).attr('data-title'), channel_id: $(button).attr('data-channelid'), post_id: $(button).attr('data-postid'), comments: $(button).attr('data-comments') });
self.setState({ editText: $(button).attr('data-message'), title: $(button).attr('data-title'), channel_id: $(button).attr('data-channelid'), post_id: $(button).attr('data-postid'), comments: $(button).attr('data-comments'), refocusId: $(button).attr('data-refoucsid') });
});
$(this.refs.modal.getDOMNode()).on('shown.bs.modal', function(e) {
@@ -65,7 +66,7 @@ module.exports = React.createClass({
});
},
getInitialState: function() {
return { editText: "", title: "", post_id: "", channel_id: "", comments: 0 };
return { editText: "", title: "", post_id: "", channel_id: "", comments: 0, refocusId: "" };
},
render: function() {
var error = this.state.error ? <div className='form-group has-error'><label className='control-label'>{ this.state.error }</label></div> : null;