2012-02-07 8 views
1

...JQMのpagebeforechangeとイベントソース

$(文書).bind( "pagebeforechange"、機能(イベント、データが){

//イベントがアンカータグからトリガーされます... //アンカー(またはevent.srcElement)への参照を取得することは可能ですか

});

または .....

誰かがそれを試してみたい場合は、以下の簡単なサンプル...

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

次の答えは http://stackoverflow.com/questions/11106172/determine-caller-of-jquery-mobiles-pagebeforechange-event/21969490#21969490役立ちますかどうかを確認してください – Michael

+0

回答を以下の私の答えかどうかを確認しますあなたの質問。 http://stackoverflow.com/questions/11106172/determine-caller-of-jquery-mobiles-pagebeforechange-event/21969490#21969490 – Michael

答えて

0

どの程度 event.liveFired.activeElement。

+0

本当に...何event.liveFired – poonkave

+0

はありません、私はイベントが表示されませんffとchromeで.liveFired。どのブラウザを使用していますか? – bmurmistro

+0

デバッグの方法が同じかどうかわかりません。 9行目にブレークポイントを入れてコンソールにイベントを入力してデバッグします。以下は私が見ることができるものです。 – poonkave

関連する問題