我找到以下jquery/checkbox行为的原因时遇到问题.
$( this.obj + ' table.sgrid-content > thead > tr > th > input.select_all' ).on( 'click' , {grid:this} , function(event){
var grid = event.data.grid;
if( $(this).is(':checked') ){
$( grid.obj + ' table.sgrid-content > tbody > tr > td > input.select ' ).attr('checked','checked');
$( grid.obj + ' .sgrid-content > tbody > tr > td > input.select ' ).parents('tr').addClass('ui-state-highlight');
} else {
$( grid.obj + ' table.sgrid-content > tbody > tr > td > input.select ' ).removeAttr('checked');
$( grid.obj + ' table.sgrid-content …
Run Code Online (Sandbox Code Playgroud) 我准备了以下React组件(React版本1.5.2):
var QuickSearch = React.createClass({
searchHandler: function(){
this.props.parent.props.dataSource.search = this.refs.SearchInput.value;
this.props.parent.props.dataSource.setPage(1);
this.props.parent.getData();
},
refreshHandler: function(){
this.props.parent.props.dataSource.search = this.refs.SearchInput.value;
this.props.parent.getData();
},
myEventHandler: function(evt){
console.log(evt);
if(evt.keyCode === 13) {
evt.stopPropagation();
this.searchHandler();
}
},
render: function(){
/* Translation function from table model */
_ = this.props.parent.props.table_model.gettrans;
return(
<div className="reactable-quicksearch-wrapper">
<input ref="SearchInput" type="text" onKeyPress={this.myEventHandler} placeholder={_('Search phrase...')} />
<button ref="SearchButton" type="button" onClick={this.searchHandler}>{_('Search')}</button>
<button ref="RefreshButton" type="button" onClick={this.refreshHandler}>{_('Refresh')}</button>
</div>
);
}
});
Run Code Online (Sandbox Code Playgroud)
myEventHandler函数作为"evt"传递包含"target"(基本上是输入)和处理程序的Proxy对象:
Proxy { <target>: Object, <handler>: Object }
Run Code Online (Sandbox Code Playgroud)
我不知道为什么,但它似乎表现得像"提交"(??)无论如何,从我读过的反应应该通过标准事件对象,但事实并非如此.
什么可以导致这种行为?
checkbox ×1
checked ×1
events ×1
javascript ×1
jquery ×1
onkeydown ×1
onkeypress ×1
reactjs ×1