Table of Contents
thinkPHP实现瀑布流的方法,thinkphp实现瀑布
Home php教程 php手册 thinkPHP实现瀑布流的方法,thinkphp实现瀑布

thinkPHP实现瀑布流的方法,thinkphp实现瀑布

Jun 13, 2016 am 09:19 AM
dreamweaver thinkphp Waterfalls flow

thinkPHP实现瀑布流的方法,thinkphp实现瀑布

本文实例讲述了thinkPHP实现瀑布流的方法。分享给大家供大家参考。具体分析如下:

很多人都想做瀑布流的效果,这里告诉大家官网使用的方法,首先要下载瀑布流的插件jquery.masonry.min.js 地址:http://masonry.desandro.com/index.html里面包含的很多示例.

流程:

1. 页面初始化时,调用插件进行一次排版;

2. 当用户将滚动条拖到底部时,用ajax加载一次数据,并排版显示

3. 重复2,直到无数据

Html代码:

复制代码 代码如下:

 
 

 
 
Insert title here 
 
 
 
 
 
 
 
 
 
 
 
 
 
瀑布流下来了
 
 
 
 
 
 
 
加载中,请稍后... 
 
 
 
 
 
 
 

Action代码:

复制代码 代码如下:

//初始化的数据 
public function lists(){  
$data = D('Info')->order('id DESC')->limit(10)->select(); 
$this->assign('data', $data); 
$this->display(); 

//获取一次请求的数据 
public function getMore(){  
//获取最后一个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); 
}

注意:通过判断窗口是否滚动到页面底部来决定用ajax加载一次数据,如果不做处理,会一下子请求很多次,所以,要使用条件来限制.

这里使用的是往一个元素上赋值 $("#loading").data("on", true);,在请求期间判断是true则不继续请求,然后在页面请求完成后再赋值为false.

希望本文所述对大家的ThinkPHP框架程序设计有所帮助。

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to adjust text position in dreamweaver How to adjust text position in dreamweaver Apr 09, 2024 am 02:24 AM

Adjusting the text position in Dreamweaver can be completed by the following steps: Select the text and use the text position adjuster to make horizontal adjustments: left alignment, right alignment, center alignment; 2. Make vertical adjustments: top alignment, bottom alignment, vertical center; 3. Press Shift key and use the arrow keys to fine-tune the position; 4. Use shortcut keys to quickly align: left alignment (Ctrl/Cmd + L), right alignment (Ctrl/Cmd + R), center alignment (Ctrl/Cmd + C).

How to add video to dreamweaver webpage production How to add video to dreamweaver webpage production Apr 09, 2024 am 01:42 AM

Embed video using Dreamweaver: Insert a video element. Select and upload a video file. Set video type, URL, size, autoplay and controls. Insert video. Optional: Customize the video appearance.

How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

How to adjust line spacing in dreamweaver How to adjust line spacing in dreamweaver Apr 09, 2024 am 03:00 AM

Adjusting line spacing in Dreamweaver is a four-step process: select the text, open the Paragraph panel, adjust the Line Spacing options, and finally click OK to apply the changes.

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

How to add pictures to dreamweaver How to add pictures to dreamweaver Apr 09, 2024 am 03:30 AM

To insert a picture in Dreamweaver, click the Insert menu and choose Image, then navigate to the picture file and select it. Other methods include dragging and dropping files or inserting HTML code directly. Adjusting properties includes changing size, alignment, adding borders, and entering alt text.

How to set dreamweaver font How to set dreamweaver font Apr 09, 2024 am 02:54 AM

You can set fonts in Dreamweaver by selecting a font, size, and color using the Properties panel. Use CSS to set fonts for your entire website or specific elements. Set the font directly in the HTML code using the "font" tag.

See all articles