在以前的一篇文章中涉及到自定义的分页:http://www.cnblogs.com/zhuqil/archive/2010/01/02/custompagingandlisting.html,今天在其中加入一个小功能:用你的鼠标拖拽进行分页:鼠标向右拖翻到后一页;鼠标向左拖,翻到前一页。
首先下载最新版本的jQuery 和jGesture 插件。在以前的分页源程序中加入下面代码。
js
<
script src
=
"
Scripts/jquery-1.3.1.js
"
type
=
"
text/javascript
"
><
/
script>
< script src = " Scripts/jgesture-1.0.3.js " type = " text/javascript " >< / script>
< script type = " text/javascript " >
$().ready( function () {
$().gesture( function (gs) {
var gestureName = gs.getName();
var intPageIndex = document.getElementById( ' txtHidPageIndex ' ).value
if (gestureName == " right " ) {
doPaging( ++ intPageIndex);
}
else if (gestureName == " left " ) {
if (intPageIndex > 1 )
doPaging( -- intPageIndex);
}
});
});
< / script>
< script src = " Scripts/jgesture-1.0.3.js " type = " text/javascript " >< / script>
< script type = " text/javascript " >
$().ready( function () {
$().gesture( function (gs) {
var gestureName = gs.getName();
var intPageIndex = document.getElementById( ' txtHidPageIndex ' ).value
if (gestureName == " right " ) {
doPaging( ++ intPageIndex);
}
else if (gestureName == " left " ) {
if (intPageIndex > 1 )
doPaging( -- intPageIndex);
}
});
});
< / script>
用gestureName进行判断,如果鼠标向右拖拽,intPageIndex++,如果鼠标向左拖拽,intPageIndex--。
本文转自麒麟博客园博客,原文链接:http://www.cnblogs.com/zhuqil/archive/2010/01/30/gesturePage.html,如需转载请自行联系原作者