Last active
February 9, 2017 04:00
-
-
Save fourcolors/50965ac529f3d3538e34 to your computer and use it in GitHub Desktop.
ReactJS with jQuery Dialog // source http://jsbin.com/zunud/4
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<link href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.min.css" rel="stylesheet" type="text/css" /> | |
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script> | |
<script src="//code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script> | |
<script src="http://fb.me/react-0.3.0.js"></script> | |
<script src="http://fb.me/JSXTransformer-0.3.0.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="component"></div> | |
<script type="text/jsx"> | |
/** @jsx React.DOM */ | |
var DialogContent = React.createClass({ | |
render: function(){ | |
return( | |
<div> | |
<form onSubmit={this.handleSubmit}> | |
<input ref="inputText" /> | |
<input type="submit" /> | |
<button onClick = {this.props.closeDialog}>Cancel</button> | |
</form> | |
</div> | |
) | |
} | |
}); | |
var DialogExample = React.createClass({ | |
openDialog: function(e){ | |
e.preventDefault(); | |
var $dialog = $('<div>').dialog({ | |
title: 'Example Dialog Title', | |
width: 400, | |
close: function(e){ | |
React.unmountAndReleaseReactRootNode(this); | |
$( this ).remove(); | |
} | |
}); | |
var closeDialog = function(e){ | |
e.preventDefault(); | |
$dialog.dialog('close'); | |
} | |
React.renderComponent(<DialogContent closeDialog={closeDialog} />, $dialog[0]) | |
}, | |
render: function(){ | |
return( | |
<button onClick= {this.openDialog}>Open Dialog</button> | |
) | |
} | |
}); | |
React.renderComponent(<DialogExample />, document.getElementById('component')); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment