-
-
Save sophiebits/8838019 to your computer and use it in GitHub Desktop.
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
<!doctype html> | |
<html> | |
<head> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-shim.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-sham.js"></script> | |
<script src="http://fb.me/react-0.8.0.min.js"></script> | |
<script src="http://fb.me/JSXTransformer-0.8.0.js"></script> | |
<script type="text/jsx"> | |
/** @jsx React.DOM */ | |
var InputBox = React.createClass({ | |
onKeyUp: function(e){ | |
var value = this.refs.mask.getDOMNode().value.trim(); | |
this.refs.mask.getDOMNode().value = "-" + value; | |
}, | |
render: function(){ | |
return ( | |
<form> | |
<input type="text" placeholder="Something to mask" | |
ref="mask" onKeyUp={this.onKeyUp} /> | |
</form> | |
); | |
} | |
}); | |
React.renderComponent( | |
<InputBox />, | |
document.getElementById('content') | |
); | |
</script> | |
</head> | |
<body style="font-size: 1.5em"> | |
<h1>Let's React</h1> | |
<div id="content"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment