Adding JQM swipe event to listview link

前端 未结 2 1648
谎友^
谎友^ 2020-12-18 14:17

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

相关标签:
2条回答
  • 2020-12-18 14:30

    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
    0 讨论(0)
  • 2020-12-18 14:40

    should be pretty easy according to documentation

    <li id="listitem"></li>
    
    pageCreate() {
      $("#listitem").swiperight() {
         $.mobile.changePage("url");
      }
    }
    
    0 讨论(0)
提交回复
热议问题