将JQM滑动事件添加到listview链接

时间:2011-09-04 11:34:07

标签: jquery jquery-mobile

我试图找到有关如何编写jquery移动滑动事件代码的任何示例。虽然我理解使用滑动和水龙头等的原理,但我很难找到一个工作。如果有人可以向我展示一个使用带有href或listview href滑动的小例子,我将不胜感激。感谢

<p>
 <ul data-role="listview" data-inset="true" data-theme="c">
  <li id="listitem"><a href="#" data-transition="flip">Requests</a><p>Box requests include, Retrieval, Return, New Intake</p></li>
  <li><a href="./speakers.php" data-transition="pop">Control Panel</a><p>Add Departments, Change Password etc</p></li>
  <li><a href="./information.html">Information</a><p>System messages, announcements are shown here</p></li>
 </ul>
</p>

<script>

pageCreate() {
  $("#listitem").swiperight() {
     $.mobile.changePage("requests.php");
  }
}

</script>

2 个答案:

答案 0 :(得分:4)

直播示例:

JS:

$("#listitem").swiperight(function() {
    $.mobile.changePage("#page1");
});

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>

相关:

答案 1 :(得分:0)

根据{{​​3}}

应该很简单

<li id="listitem"></li>

pageCreate() {
  $("#listitem").swiperight() {
     $.mobile.changePage("url");
  }
}