Jquery-ajax-php+ajax The checkbox check box is selected when paging

Source: Internet
Author: User
Purpose: All data are paged, not all data, but fixed number of bars at a time. and the data ID that is selected on each page can be saved, together with the selected data, do the corresponding action. For example, the first page selected 2, the second page selected 3, the submission is 5, if the first page, this also shows the selected data, back to the second page, the selected data will be displayed, and so on, uncheck, turn the page several times, no problem;
How can this be achieved?.. Paging this is fine with me, but this check box is next to the page and it will be refreshed.

Reply content:

Purpose: All data are paged, not all data, but fixed number of bars at a time. and the data ID that is selected on each page can be saved, together with the selected data, do the corresponding action. For example, the first page selected 2, the second page selected 3, the submission is 5, if the first page, this also shows the selected data, back to the second page, the selected data will be displayed, and so on, uncheck, turn the page several times, no problem;
How can this be achieved?.. Paging this is fine with me, but this check box is next to the page and it will be refreshed.

Two scenarios

Scenario 1
- - -
1. A separate container (DIV) for each page.

            ...    

2. When loading a new page, first check that the page has been loaded, such as loading page 4

The code is only indicative if ($ ('. Page-4 ', '. Content '). Length > 0) {    $ ('. Page ', '. Content '). Hide ();    $ ('. Page-4 ', '. Content '). Show (); else {    page4 = Render_page (Load_page (4));//Get the structure of the Page4    $ ('. Page ', '. Content '). Hide ();    $ ('. Content '). Append (page4);}

This allows you to save the page information when you switch the page.

Scenario 2
- - -
Create an object to hold the page data, and let it support custom events. When PAGE the content has changed, re-follow PAGE the rendering. This is actually an MVC scenario.

The following code is handy to write, just to signal. Do not use directly.

can use Eventemitter and so on event library to support, I here in order to simply use jquery var PAGE = $ ({current    :-1,    data: {}}); Page.extend ({    fetch:function () {        $.get (' url ', function (data) {            This.data[current_page] = data            This.trigger (' Value_change ')    })},    show:function (page) {        page.current = page;        if (This.data[page]) {            this.trigger (' Value_change ');        } else {            this.fetch (page);        }    }); Page.bind (' Value_change ', function () {    render_page ();}); var render_page = function () {        if (Page[page.current]) {            //render Div#page content as content of page[page.current]        } else {            throw (' Error ');        }    }; $ (' input[type= ' checkbox "] ', ' #page '). Change (function () {    //Update page content    Page.data[current_page][item] = Value    Page.trigger (Value_change);});

When selected, use an array variable a[] to save the selected ID;

Is the part of the previous page of the page of HTML deleted or hidden? It must have been erased.

It's like a shopping cart, isn't it? Each page of selected items is thrown into the shopping cart and processed in batches.

I used the codeigniter in the shopping cart class to deal with this situation. The principle is to use the session to store the selected ID, each ID will generate a unique rowid , when the page is rendered according to the generated rowid judge whether the current item is selected.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.