Write down jquery's carriage return event. The Code is as follows:
Global:
Copy codeThe Code is as follows: $ (function (){
Document. onkeydown = function (e ){
Var ev = document. all? Window. event: e;
If (ev. keyCode = 13 ){
$ ('# FormId). submit (); // process the event
}
}
});
A control:Copy codeThe Code is as follows: $ ('# id'). keydown (function (e ){
If (e. keyCode = 13 ){
$ ('# FormId). submit (); // process the event
}
});
If (window. event. keyCode = 13) window. event. keyCode = 0 // then the Enter key is canceled.
If you want to simulate the Tab key, you just need to write it as if (window. event. keyCode = 13) window. event. keyCode = 9, and it will jump to another element.
As we all know, in Pagination of easyui, to jump to a page, you only need to ENTER the page number and press ENTER to achieve the effect. Some time ago, the project customer requested to enter the page number and press the GO button to redirect. Well, the customers are God. What do they say about us, these programmers can only do their best to achieve the results.
That is, press GO to input 3 and press Enter.
This problem can be simplified to clicking a label to simulate Pagination page number input box press enter, but this event is written in jquery. easyui. min. js, We can't directly call it; the page number input box found through chrome is
Copy codeThe Code is as follows: <input class = "pagination-num" type = "text" value = "1" size = "2">
Then, we checked the Event Object of jquery api and found that jquery has a trigger method that can trigger simulated button events. Directly Add codeCopy codeThe Code is as follows: <script language = "javascript" type = "text/javascript">
$ (Document). ready (function (){
$ ("# Test"). datagrid ({
Url: "/Test/Test1Data ",
Type: "post ",
Datatype: "json ",
Width: 465,
Height: 280,
LoadMsg: "loading data. Please wait ...",
FitCloumns: true,
Nowrap: true,
Rownumbers: false,
Pagination: true,
SingleSelect: true,
ShowFooter: true,
Columns :[[
{Field: 'testname', title: 'test name', width: 230, editor: 'text '},
{Field: 'testvalue', title: 'test value', width: 230, align: 'center '}
]
});
$ ("# Test"). datagrid ('getpager'). pagination ({
ShowPageList: false,
ShowRefresh: false,
BeforePageText: "th ",
AfterPageText: "page <a href = 'javascript: void (0) 'onclick = 'goenterpage () '> </a>, total pages of {pages ",
DisplayMsg: 'Current {from} to {to}, total {total'
});
}); // See the easyui documentation for the above Code parameters.
Function GoEnterPage (){
Var e = jQuery. Event ("keydown"); // simulate a keyboard Event
E. keyCode = 13; // keyCode = 13 is the carriage return
$ ("Input. pagination-num"). trigger (e); // press enter in the simulated page number box.
}
</Script>
Easyui: http://www.jeasyui.com/index.php
Jquery: http://jquery.com/
Here is a jquery Chinese manual, the description is very full: http://jquery.org.cn/manual/