jquery只在phonegap中使用index.html

时间:2015-08-18 09:48:08

标签: jquery cordova jquery-mobile phonegap-plugins cordova-plugins

问题是Jquery在index.html中正常工作。如果我点击注册按钮打开register.html页面。但在这里Jquery工作停止。如果我从头部删除Mobile Jquery Link,那么一切都很完美......

Index.html - index.html工作正常。

<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> 
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script src="js/function.js"></script>
<script src="js/comman_phoneGap.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script> 

Register.html - :问题在这里。我的剧本有什么问题

<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>         
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script src="js/function.js"></script>
<script src="js/comman_phoneGap.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script> 

<form action="" method="post">   
     <div class="ui-field-contain">
          <label for="name">Full Name:</label>
           <input type="text" class="form-control" id="username" placeholder="Name">    
     </div>
     <div class="ui-field-contain">
           <label for="name">Full Name:</label>
           <input type="text" class="form-control"  id="email"  placeholder="email">
     </div>
     <div class="ui-field-contain">
            <label for="name">Full Name:</label>
            <input type="password" class="form-control" id="password"  placeholder="Password" />
      </div>           

      <div class="ui-field-contain">
            <label for="name">Full Name:</label>
            <input type="password" class="form-control" id="cpassword" placeholder="Password">
      </div>  
      <fieldset data-role="controlgroup" data-type="horizontal">
            <legend>Select Type</legend>
            <input type="radio" class="user_type" id="seller" value="seller">
            <label for="seller">Seller</label>
            <input type="radio" class="user_type" id="buyer" value="buyer">
            <label for="buyer">Buyer</label> 
      </fieldset>

      <button type="submit" onclick="return clicked();"  class="btn btn-block btn-success">Register</button> 
 </form>
 <script>
      function clicked()
       {
           alert('hello'); return false;
       }
 </script> 
  

clicked()函数在这里不起作用。我不明白。做什么。

1 个答案:

答案 0 :(得分:1)

这是临时解决方案..但是工作得很完美......

function redirect(page)
    {

       $.mobile.changePage(
        window.location.href=page,
        {
          allowSamePageTransition : true,
          transition              : 'none',
          showLoadMsg             : false,
          reloadPage              : true
         }
      );
    }

Page Reference is Here. Get proper information