Remove React.autoBind from examples
This commit is contained in:
parent
75f7f1e9ba
commit
0c1f2720b3
|
@ -14,9 +14,9 @@ var BallmerPeakCalculator = React.createClass({
|
|||
getInitialState: function() {
|
||||
return {bac: 0};
|
||||
},
|
||||
handleChange: React.autoBind(function() {
|
||||
handleChange: function() {
|
||||
this.setState({bac: this.refs.bac.getDOMNode().value});
|
||||
}),
|
||||
},
|
||||
render: function() {
|
||||
var bac;
|
||||
var pct;
|
||||
|
|
|
@ -67,18 +67,18 @@ var BootstrapModal = React.createClass({
|
|||
</div>
|
||||
);
|
||||
},
|
||||
onCancel: React.autoBind(function() {
|
||||
onCancel: function() {
|
||||
if (this.props.onCancel) {
|
||||
this.props.onCancel();
|
||||
}
|
||||
this.close();
|
||||
}),
|
||||
onConfirm: React.autoBind(function() {
|
||||
},
|
||||
onConfirm: function() {
|
||||
if (this.props.onConfirm) {
|
||||
this.props.onConfirm();
|
||||
}
|
||||
this.close();
|
||||
}),
|
||||
},
|
||||
close: function() {
|
||||
if (this.props.onClose) {
|
||||
this.props.onClose();
|
||||
|
@ -90,14 +90,14 @@ var Example = React.createClass({
|
|||
getInitialState: function() {
|
||||
return {modalVisible: false};
|
||||
},
|
||||
toggleModal: React.autoBind(function() {
|
||||
toggleModal: function() {
|
||||
this.setState({modalVisible: !this.state.modalVisible});
|
||||
}),
|
||||
handleCancel: React.autoBind(function() {
|
||||
},
|
||||
handleCancel: function() {
|
||||
if (confirm('Are you sure you want to cancel?')) {
|
||||
this.toggleModal();
|
||||
}
|
||||
}),
|
||||
},
|
||||
render: function() {
|
||||
var modal = null;
|
||||
if (this.state.modalVisible) {
|
||||
|
@ -121,4 +121,4 @@ var Example = React.createClass({
|
|||
}
|
||||
});
|
||||
|
||||
React.renderComponent(<Example />, document.getElementById('jqueryexample'));
|
||||
React.renderComponent(<Example />, document.getElementById('jqueryexample'));
|
||||
|
|
|
@ -74,17 +74,17 @@ var Utils = {
|
|||
// Begin React stuff
|
||||
|
||||
var TodoItem = React.createClass({
|
||||
handleSubmit: React.autoBind(function(event) {
|
||||
handleSubmit: function(event) {
|
||||
var val = this.refs.editField.getDOMNode().value;
|
||||
if (val) {
|
||||
this.props.onSave(val);
|
||||
}
|
||||
return false;
|
||||
}),
|
||||
onEdit: React.autoBind(function() {
|
||||
},
|
||||
onEdit: function() {
|
||||
this.props.onEdit();
|
||||
this.refs.editField.getDOMNode().focus();
|
||||
}),
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
<li class={cx({completed: this.props.todo.get('completed'), editing: this.props.editing})}>
|
||||
|
@ -166,7 +166,7 @@ var TodoApp = React.createClass({
|
|||
getBackboneModels: function() {
|
||||
return [this.props.todos];
|
||||
},
|
||||
handleSubmit: React.autoBind(function() {
|
||||
handleSubmit: function() {
|
||||
var val = this.refs.newField.getDOMNode().value.trim();
|
||||
if (val) {
|
||||
this.props.todos.create({
|
||||
|
@ -177,13 +177,13 @@ var TodoApp = React.createClass({
|
|||
this.refs.newField.getDOMNode().value = '';
|
||||
}
|
||||
return false;
|
||||
}),
|
||||
toggleAll: React.autoBind(function(event) {
|
||||
},
|
||||
toggleAll: function(event) {
|
||||
var checked = event.nativeEvent.target.checked;
|
||||
this.props.todos.map(function(todo) {
|
||||
todo.set('completed', checked);
|
||||
});
|
||||
}),
|
||||
},
|
||||
destroy: function(todo) {
|
||||
this.props.todos.remove(todo);
|
||||
},
|
||||
|
@ -194,11 +194,11 @@ var TodoApp = React.createClass({
|
|||
todo.set('title', text);
|
||||
this.setState({editing: null});
|
||||
},
|
||||
clearCompleted: React.autoBind(function() {
|
||||
clearCompleted: function() {
|
||||
this.props.todos.completed().map(function(todo) {
|
||||
todo.destroy();
|
||||
});
|
||||
}),
|
||||
},
|
||||
render: function() {
|
||||
var footer = null;
|
||||
var main = null;
|
||||
|
|
|
@ -32,24 +32,24 @@ function cx(obj) {
|
|||
}
|
||||
|
||||
var TodoItem = React.createClass({
|
||||
handleSubmit: React.autoBind(function() {
|
||||
handleSubmit: function() {
|
||||
var val = this.state.editText;
|
||||
if (val) {
|
||||
this.props.onSave(val);
|
||||
this.setState({editField: ''});
|
||||
}
|
||||
return false;
|
||||
}),
|
||||
handleEdit: React.autoBind(function() {
|
||||
},
|
||||
handleEdit: function() {
|
||||
this.props.onEdit();
|
||||
this.refs.editField.getDOMNode().focus();
|
||||
}),
|
||||
handleKey: React.autoBind(function(event) {
|
||||
},
|
||||
handleKey: function(event) {
|
||||
if (event.nativeEvent.keyCode === 27) {
|
||||
this.handleSubmit();
|
||||
}
|
||||
this.setState({editText: event.target.value});
|
||||
}),
|
||||
},
|
||||
getInitialState: function() {
|
||||
return {editText: this.props.todo.title};
|
||||
},
|
||||
|
@ -114,7 +114,7 @@ var TodoApp = React.createClass({
|
|||
};
|
||||
},
|
||||
|
||||
handleSubmit: React.autoBind(function() {
|
||||
handleSubmit: function() {
|
||||
var val = this.refs.newField.getDOMNode().value.trim();
|
||||
if (val) {
|
||||
var todos = this.state.todos;
|
||||
|
@ -127,7 +127,7 @@ var TodoApp = React.createClass({
|
|||
this.refs.newField.getDOMNode().value = '';
|
||||
}
|
||||
return false;
|
||||
}),
|
||||
},
|
||||
|
||||
toggleAll: function(event) {
|
||||
var checked = event.nativeEvent.target.checked;
|
||||
|
|
Loading…
Reference in New Issue