JQM pagebeforechange and event source

旧时模样 提交于 2019-12-24 15:33:12

问题


listening to pagebeforechange event...

$(document).bind("pagebeforechange", function ( event , data) {

//event is triggered from an anchor tag... //Is it possible to get reference to anchor( or event.srcElement) here

});

or .....

A simple sample below if somebody want to try it out...

    <head>
      <title>Main menu</title>
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css"
      />
      <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
      <script type="text/javascript">
          $(document).bind("pagebeforechange", function (event, data) {
              if (typeof data.toPage === "string") {
                  //event is triggered from an anchor tag...
                  //Is it possible to get reference to anchor( or event.srcElement)  here
                  event.preventDefault();
              }
          });
      </script>
      <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
    </head>
    <body>
      <div data-role="page" id="home">
        <div data-role="header" data-theme="a"></div>
        <div data-role="content">
          <ul data-role="listview" data-inset="true">
            <li>
              <a href="#category-items?category=animals">Animals</a>
            </li> 
          </ul>
        </div>
      </div>
    </body>

    </html>

回答1:


How about event.liveFired.activeElement;



来源:https://stackoverflow.com/questions/9179096/jqm-pagebeforechange-and-event-source

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