2010-12-07 2 views
1

私は英語ですが、英語が悪いですが、JQuery Mobileについて問題があります。 外国人の友人が私を助けてくれることを願っています。jQuery Mobile Ajax(jsは実行されません)

first:first.jspで 'General Button'をクリックしてもOKですが、 'Submit Button'はOKではありません。 秒: 'リンクボタン'をクリックし、second.jspに移動し、 'テスト'ボタンをクリックします.JavaScriptコードは実行されません!

私は知らない何が起こるのか!助けてくれますか?ありがとうございます。

first.jsp

<!DOCTYPE html> 
<%@ page contentType="text/html;charset=UTF-8" %> 
<html> 
<head> 
     <title>China</title> 
     <meta charset="utf-8" /> 
     <link rel="stylesheet" href="/mobile/mobile/common/script/jQuery/jquery.mobile-1.0a2.css" /> 
     <script type="text/javascript" src="/mobile/mobile/common/script/jQuery/jquery-1.4.4.js"></script> 
     <script type="text/javascript" src="/mobile/mobile/common/script/jQuery/jquery.mobile-1.0a2.js"></script> 
     <script> 
      $(function(){ 
       $('#Button').click(function(){ 
        alert('This is a general button!'); 
       }); 
       $('#ButtonSubmit').click(function(){ 
        alert('This is a submit button!'); 
       }); 
      }); 
     </script> 
    </head> 
    <body> 
     <div id="page" data-role="page" data-theme='d'> 
      <div data-role="header" data-position="inline" data-position="fixed"> 
       <h1>Chinese</h1> 
      </div> 
      <div data-role="content"> 
       <a id="Button" data-role='button' data-iconpos="right" data-icon="gear">General Button</a> 
       <a id="ButtonSubmit" data-role='button' data-iconpos="right" type="submit" data-icon="gear">Submit Button</a> 
       <a id="link" href="/mobile/mobile/second.jsp" data-role='button' data-iconpos="right" data-icon="gear">Link Button</a> 
      </div> 
      <div data-role="footer" data-position="fixed"> 
       <h1>[Email:[email protected]][1]</h1> 
      </div> 
     </div> 
    </body> 
</html> 

second.jsp

<!DOCTYPE html> 
<%@ page contentType="text/html;charset=UTF-8" %> 
<html> 
<head> 
     <title>China</title> 
     <meta charset="utf-8" /> 
     <link rel="stylesheet" href="/mobile/mobile/common/script/jQuery/jquery.mobile-1.0a2.css" /> 
     <script type="text/javascript" src="/mobile/mobile/common/script/jQuery/jquery-1.4.4.js"></script> 
     <script type="text/javascript" src="/mobile/mobile/common/script/jQuery/jquery.mobile-1.0a2.js"></script> 

     <script> 
      $(function(){ 
       $('#test').click(function(){ 
        alert('This is a general button!'); 
       }); 
      }); 
     </script> 
    </head> 
    <body> 
     <div id="page" data-role="page" data-theme='d'> 
      <div data-role="header" data-position="inline" data-position="fixed"> 
       <h1>[Chinese][2]</h1> 
      </div> 
      <div data-role="content"> 
       <a id="test" data-role='button' data-iconpos="right" data-icon="gear">Test</a> 
      </div> 

      <div data-role="footer" data-position="fixed"> 
       <h1>Email:[email protected]</h1> 
      </div> 
     </div> 
    </body> 
</html> 


    [1]: http://[email protected] 
    [2]: http://[email protected] 

答えて

1

#ButtonSubmit

type="submit"を削除し、それはボタンのように見えるので、uは、あなたのボタンのスタイルを設定したい場合は、herを見てみましょう。

+0

ありがとうございます! – ZhaoSheng

+0

$(function(){ $( '#test')クリック(function(){ アラート( 'これは一般的なボタンです'); }); }); – ZhaoSheng

+0

「second.jsp」ページの「テスト」ボタンのクリックイベントが追加されないのはなぜですか?なぜですか? javascriptコードが実行されていないように見えます;なぜそれが起こったのか教えてください。 – ZhaoSheng

0

jQuery Mobileは、ページの変更にajaxを使用しています。このイベントコールでは、イベント「ページショー」またはその他の実行にlive()またはdelegate()が必要です。

関連する問題