Created
March 4, 2014 00:12
-
-
Save steida/9337512 to your computer and use it in GitHub Desktop.
React.js with dependency injection based on types. Snippet from Este.js (not released yet).
This file contains 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
/** @jsx React.DOM */ | |
goog.provide('app.drugs.react.DrugAutoComplete'); | |
goog.require('este.thirdParty.react'); | |
goog.require('goog.ui.ac.AutoComplete'); | |
/** | |
* @param {app.Routes} routes | |
* @constructor | |
*/ | |
app.drugs.react.DrugAutoComplete = function(routes) { | |
this.reactClass = React.createClass(/** @lends {React.ReactComponent.prototype} */{ | |
render: function() { | |
return ( | |
<div className="drug-autocomplete"> | |
<input | |
className="form-control" | |
placeholder={this.props.placeholder} | |
onFocus={this.onInputFocus} | |
ref="input" | |
/> | |
<button className="search" onFocus={this.onButtonFocus} tabIndex="-1"> | |
search drug | |
</button> | |
</div> | |
); | |
}, | |
// Some Closure Library handler using injected app.Routes instance. | |
onAutoCompleteUpdate: function(e) { | |
this.refs['input'].getDOMNode().value = '' | |
var drugUrlName = e.row; | |
routes.redirectToDrugsDetail(drugUrlName); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment