Thinkphp method of realizing waterfall flow _php

Source: Internet
Author: User
Keywords thinkphp Waterfall Stream
This paper describes the method of thinkphp to realize waterfall flow. Share to everyone for your reference. The specific analysis is as follows:

Many people want to do waterfall flow effect, here to tell you how to use the official website, the first to download waterfall stream plug-in jquery.masonry.min.js address: http://masonry.desandro.com/index.html contains a lot of examples.

Process:

1. When the page is initialized, call the plugin to make a layout;

2. When the user drags the scroll bar to the bottom, the data is loaded with Ajax and the layout is displayed

3. Repeat 2 until no data is

HTML code:

The code is as follows:





<title>Insert Title here</title>













The waterfall is coming down.






load, please later ...



I'm the footer.



Action Code:

The code is as follows:

Initialized data
Public function lists () {
$data = D (' Info ')->order (' id DESC ')->limit (Ten)->select ();
$this->assign (' data ', $data);
$this->display ();
}
Get the requested data once
Public Function Getmore () {
Get last ID
if (!emptyempty ($_get[' LastID '))) $map [' id '] = array (' lt ', $_get[' LastID ']);
$data = D (' Info ')->where ($map)->order (' id DESC ')->limit (Ten)->select ();
$this->ajaxreturn ($data);
}

Note: by judging whether the window is scrolled to the bottom of the page to decide to load the data with Ajax, if you do not do processing, will be requested many times, so, to use conditions to limit.

This is used to assign a value of $ ("#loading") to an element. Data ("On", true), when the request is true, does not continue the request, and then assigns a value of false after the page request is completed.

It is hoped that this article will be helpful to everyone's thinkphp framework design.

  • 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.