Home  >  Article  >  Backend Development  >  ThinkPHP implements waterfall flow method, thinkphp implements waterfall_PHP tutorial

ThinkPHP implements waterfall flow method, thinkphp implements waterfall_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:12:40979browse

thinkPHP implements waterfall flow method, thinkphp implements waterfall

The example in this article describes how thinkPHP implements waterfall flow. Share it with everyone for your reference. The specific analysis is as follows:

Many people want to make the effect of waterfall flow. Here I will tell you how to use the official website. First, download the waterfall flow plug-in jquery.masonry.min.js. Address: http://masonry.desandro.com/index.html It contains many examples.

Process:

1. When the page is initialized, the plug-in is called to perform layout once;

2. When the user drags the scroll bar to the bottom, use ajax to load the data once and format it for display

3. Repeat 2 until there is no data

Html code:

Copy code The code is as follows:
 
 
 
 
Insert title here 
 
 
 
 
 
 
 
 
 
 
 
 
 
瀑布流下来了
 
 
 
 
 
 
 
加载中,请稍后... 
 
 
 
 
 


Action code:

Copy code The code is as follows:
//Initialized data
public function lists(){
$data = D('Info')->order('id DESC')->limit(10)->select();
$this->assign('data', $data);
$this->display();
}
//Get the data requested once
public function getMore(){
//Get the last id
if(!emptyempty($_GET['lastid']))$map['id'] = array('lt', $_GET['lastid']);
$data = D('Info')->where($map)->order('id DESC')->limit(10)->select();
$this->ajaxReturn($data);
}

Note: Determine whether to use ajax to load data once by judging whether the window has scrolled to the bottom of the page. If it is not processed, it will be requested many times at once, so conditions must be used to limit it.

What is used here is to assign a value to an element $("#loading").data("on", true);. If it is judged to be true during the request, the request will not continue, and then the value will be assigned after the page request is completed. false.

I hope this article will be helpful to everyone’s ThinkPHP framework programming.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/919626.htmlTechArticlethinkPHP implements waterfall flow, thinkphp implements waterfall. This article describes how thinkPHP implements waterfall flow. Share it with everyone for your reference. The specific analysis is as follows: Many people want to...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn