Last active
November 25, 2016 22:28
-
-
Save illmatix/2e6698e9e924cd7bc5f5d08a7d3eb01e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @desc Primary jsx file for the fancy search react component. | |
| * @author Chad Payne chad@simplesimple.ca | |
| */ | |
| var FancySearchInput = React.createClass({ | |
| getInitialState: function() { | |
| var string; | |
| if(typeof this.props.text !== 'undefined') { | |
| string = this.props.text.length ? this.props.text : ''; | |
| } else { | |
| string = ''; | |
| } | |
| return {text: string}; | |
| }, | |
| shouldComponentUpdate(nextProps, nextState) { | |
| var shouldComponentUpdate = this.props.text !== nextProps.text || this.state.text !== nextState.text; | |
| return shouldComponentUpdate; | |
| }, | |
| /** | |
| * Input submit handler | |
| */ | |
| onChange: function (e) { | |
| console.log('onChange'); | |
| console.log('') | |
| this.setState({text: e.target.value }); | |
| // this.$form = jQuery(React.findDOMNode(this)).parents('.content').first().find('form#views-exposed-form-search-solr-solr-search-block'); | |
| // this.$form.find('.form-item-search-api-views-fulltext input').val(e.target.value).change(); | |
| }, | |
| /** | |
| * Render sub components of the fancy search | |
| */ | |
| render: function () { | |
| var value = this.state.text; | |
| return <input type="text" className="fancy-search-text" value={value} onChange={this.onChange} placeholder="Search..." />; | |
| } | |
| }); | |
| module.exports = FancySearchInput; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment