Skip to content

Commit

Permalink
Merge pull request #5 from bsurai/add-keyboard-element
Browse files Browse the repository at this point in the history
addKeyBoardToDOM method as separated method
  • Loading branch information
Utzel-Butzel authored Jul 25, 2017
2 parents b5ab1b5 + 36e1c82 commit 5af27c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 7 additions & 1 deletion dist/Keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ var _class = function (_React$Component) {
}

//Add jQuery Keyboard to DOM Element
(0, _jquery2.default)(_reactDom2.default.findDOMNode(this.refs.keyboard)).keyboard(this.props.options);
// (0, _jquery2.default)(_reactDom2.default.findDOMNode(this.refs.keyboard)).keyboard(this.props.options);
this.addKeyBoardToDOM();

// Update while typing if usePreview is false
if (this.props.options.usePreview === false) {
Expand All @@ -89,6 +90,11 @@ var _class = function (_React$Component) {
}
}
}, {
key: 'addKeyBoardToDOM',
value: function addKeyBoardToDOM() {
(0, _jquery2.default)(_reactDom2.default.findDOMNode(this.refs.keyboard)).keyboard(this.props.options);
}
},{
key: 'clear',
value: function clear() {
this.setState({ value: '' });
Expand Down
9 changes: 7 additions & 2 deletions lib/Keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default class extends React.Component {
this.state = { value: "", className: 'keyboard-wrapper' };
this.handleChange = this.handleChange.bind(this);
}

componentDidMount() {
// Set Value to Input Element on Accept
this.setState({ value: this.props.value });
Expand Down Expand Up @@ -39,8 +40,9 @@ export default class extends React.Component {
}.bind(this);
}

//Add jQuery Keyboard to DOM Element
jQuery(ReactDOM.findDOMNode(this.refs.keyboard)).keyboard(this.props.options);
// Add jQuery Keyboard to DOM Element
// jQuery(ReactDOM.findDOMNode(this.refs.keyboard)).keyboard(this.props.options);
this.addKeyBoardToDOM();

// Update while typing if usePreview is false
if (this.props.options.usePreview === false) {
Expand All @@ -49,6 +51,9 @@ export default class extends React.Component {
}.bind(this));
}
}
addKeyBoardToDOM() {
jQuery(ReactDOM.findDOMNode(this.refs.keyboard)).keyboard(this.props.options);
}
clear() {
this.setState({ value: '' });
}
Expand Down

0 comments on commit 5af27c8

Please sign in to comment.