bol*_*llo 27 jquery jquery-mobile
我有一个listview,我想要做的是在链接上添加一个滑动事件.例如,如果用户滑动第一个链接,则会转到该页面.这可能与listview元素一起使用.我试过div,href,a,li,ul但仍然没有警报.它适用于身体.谢谢
<div>
<ul data-role="listview" data-inset="true">
<li class="rqstpage"><a href="./requests.php">Requests</a></li>
<li><a href="./speakers.php" data-transition="pop">Control Panel</a></li>
<li><a href="./schedule.html">Schedule</a></li>
<li><a href="./information.html">Information</a></li>
</ul>
</div>
<script>
$("div ul li.rqstpage").bind('swipe',function(event, ui){
$.mobile.changePage("requests.php", "slide");
});
</script>
Run Code Online (Sandbox Code Playgroud)
Phi*_*ord 29
实例:
JS:
$("#listitem").swiperight(function() {
$.mobile.changePage("#page1");
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<div data-role="page" id="home">
<div data-role="content">
<p>
<ul data-role="listview" data-inset="true" data-theme="c">
<li id="listitem">Swipe Right to view Page 1</li>
</ul>
</p>
</div>
</div>
<div data-role="page" id="page1">
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="c">
<li data-role="list-divider">Navigation</li>
<li><a href="#home">Back to the Home Page</a></li>
</ul>
<p>
Yeah!<br />You Swiped Right to view Page 1
</p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
有关:
你尝试过使用绑定live()
吗?
更新:.live()
将被弃用并且正确使用.on()
它将处理程序附加到所有当前匹配元素的事件以及稍后可能匹配的元素.
pageCreate() {
$(parent).on('swipe', 'li.rqstpage', function() {
$.mobile.changePage("requests.php", "slide");
}
}
Run Code Online (Sandbox Code Playgroud)
您是否考虑过使用此库进行手势?
归档时间: |
|
查看次数: |
92412 次 |
最近记录: |