Under normal circumstances, if the content selected by js clicks is refreshed on the page or the page turns out to disappear, I will introduce a method to enable page turning to keep the checkbox check status. For more information, see.
Implementation principle:
Each page is contained in a div with the id of page + page. When you flip to another page, you can hide the current page. First, you can determine whether the target page has been loaded, if no page exists, you can use ajax to retrieve the page, which is also contained in the div of a page + page. This means that all pages are in the page, however, the div of a non-current page is set to display = none, so you may find out how fast the loaded page can be loaded.
The core part is the javascript function:
The Code is as follows: |
Copy code |
// Display the page number. Function show_search_page (page_num) { // First, determine whether the target page has been loaded. If the target page has been loaded, hide all other pages, display the current page, and return the result. If ($ chk ($ ('page' + page_num ))) { $ ('Song _ div '). getElements ('div [id ^ = page] '). each (function (item, index) {$ (item ). setStyle ('display', 'None ');}); $ ('Page' + page_num). setStyle ('display', 'block '); Return; } // If it has not been loaded, obtain page data through ajax, generate a page + page div, and display it Var search_song_with_ajax = new Ajax ('./getsearchdata. php? Cur_page = '+ page_num +' & amp; key = {_$ search_key _}', {Method: 'get ', OnComplete: function (){ $ ('Song _ div '). getElements ('div [id ^ = page] '). each (function (item, index) {$ (item ). setStyle ('display', 'None ');}); Var new_div = new Element ('div ',{ 'Id': 'page' + page_num }); $ (New_div). setHTML (this. response. text ); $ (New_div). injectInside ('song _ div '); } }). Request (); }
|
Javascript code can be viewed on the page, hope it usefull for you