Code Monkey home page Code Monkey logo

pager's Introduction

Pager

シンプルなページング用Javascriptライブラリです。 サーバサイドでのページング処理ではなく、全データをJSONで画面に渡し、Javascriptでページング処理を行います。

Hogan.jsをテンプレートエンジンとして使っています。

使い方は以下です。

<!DOCTYPE html>
<html>
<head>
	<script type="text/javascript" src="jquery-2.1.0.min.js"></script>
	<script type="text/javascript" src="hogan.min.js"></script>
	<script type="text/javascript" src="pager.js"></script>
	<script>
		$(function() {
			var data = [
				{a: 1, b: 2, c:3}
				, {a: 4, b: 5, c:6}
				, {a: 7, b: 8, c:9}
				, {a: 10, b: 11, c:12}
				, {a: 13, b: 14, c:15}
			];

			var page = new Pager({
				id: '#table'
				, data: data
				, page_size: 10
				, template: $('#template').text()
			});
			page.show_page();

		});
	</script>
	<script type="text/template" id="template">
		<table>
			<thead>
			<tr>
				<th>a</th>
				<th>b</th>
				<th>c</th>
			</tr>
			</thead>
			<tbody>
			{{#data}}
			<tr>
				<td>{{a}}</td>
				<td>{{b}}</td>
				<td>{{c}}</td>
			</tr>
			{{/data}}
			</tbody>
		</table>
		{{#has_prev_page}}
		<button type="button" class="prev"><</button>
		{{/has_prev_page}}
		{{#page_numbers}}
		<a href="javascript:void(0);" class="move" data-page-number="{{.}}">{{.}}</a>
		{{/page_numbers}}

		{{#has_next_page}}
		<button type="button" class="next">></button>
		{{/has_next_page}}
	</script>
</head>
<body>
<h2>Pager test</h2>
<div id="table"></div>
<div>
	powered by wata
</div>
</body>
</html>

pager's People

Contributors

wata-gh avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.