-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathexample.js
35 lines (33 loc) · 1.1 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* @jsx React.DOM
*/
(function() {
var App = React.createClass({
searchRequested: _.debounce(function(key, cb) {
axios.get('http://corsify.appspot.com/http://vocab.nic.in/rest.php/country/json').then(function(resp) {
cb(resp.data.countries.filter(function(one) {
return one.country.country_name.toLowerCase().indexOf(key.toLowerCase()) > -1;
}));
});
}, 3000),
getTextContentForItem: function(one) {
return one.country.country_name;
},
onSelected: function(one) {
alert('Selected: ' + one.country.country_name);
},
render: function() {
return (
<div className="container">
<h1>Example</h1>
<div className="row">
<div className="col-md-3">
<ReactBootstrapAsyncAutocomplete label="Country" placeholder="Start writing a country name" onSearch={this.searchRequested} itemContent={this.getTextContentForItem} onItemSelect={this.onSelected} />
</div>
</div>
</div>
);
}
});
React.renderComponent(App(), document.body);
})();