Adding JQM swipe event to listview link

独自空忆成欢 提交于 2019-12-29 07:15:14

问题


I am trying to find any examples on how to code jquery mobile swipe event. Although I understand the principal of using swipe and tap etc, I am struggling to get one to work. If someone could show me a small example of using swipe with a href or listview href I would be grateful. Thanks

<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>

回答1:


Live Example:

  • http://jsfiddle.net/yxzZf/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>

Related:

  • Adding jquery mobile swipe event



回答2:


should be pretty easy according to documentation

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

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


来源:https://stackoverflow.com/questions/7298915/adding-jqm-swipe-event-to-listview-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!