Jquery 页码不为';主动';phonegap JQM应用程序中的mobile.changePage重定向后

Jquery 页码不为';主动';phonegap JQM应用程序中的mobile.changePage重定向后,jquery,jquery-mobile,cordova,Jquery,Jquery Mobile,Cordova,我的phonegap应用程序中有一个奇怪的行为,我似乎无法找到解决方法 我的应用程序有一个登录表单,成功登录后会重定向到更新帐户页面 LOGIN.HTML setTimeout(function() { $.mobile.changePage('update-account.html', { reloadPage: true, transition: "slide"} ); }, 2000); 在更新帐户表单中 UPDATE-ACCOUNT.HTML <script

我的phonegap应用程序中有一个奇怪的行为,我似乎无法找到解决方法

我的应用程序有一个登录表单,成功登录后会重定向到更新帐户页面

LOGIN.HTML

setTimeout(function() {
         $.mobile.changePage('update-account.html', { reloadPage: true, transition: "slide"} );
}, 2000);
在更新帐户表单中

UPDATE-ACCOUNT.HTML

  <script type="text/javascript">

                    $(document).ready(function() {

                                      $('#updateAcc').tap(function(){

                                        var formData = $("#callUpdateForm").serialize();

                                        $.ajax({
                                               type: "POST",
                                               url: "/process/update-account.php",
                                               cache: false,
                                               dataType: 'json', // JSON response
                                               data: formData,
                                               success: function(res) {
                                               if (res.success) {
                                                 $("#notify .success").show(); //show success message
                                                 $("#notify .success").delay(2000).hide("slow");//fades it out
                                                 setTimeout(function() {
                                                    $.mobile.changePage('account.html', { reloadPage: true, transition: "fade"} ); //redirects to profile
                                                 }, 2000);
                                               } else {
                                               // show error message
                                                 $("#notify .error").show();  //show error message
                                                 $("#notify .error").delay(2000).hide("slow"); //fades it out
                                               }
                                               },
                                               error: function() {
                                               alert('not working');
                                               }
                                               });

                                        return false;

                                        });

                                      });

                    </script>

<script type="text/javascript">

             function getAccount() {
                     $.getJSON("/json/account.json.php", {id : localStorage.getItem("id")}, function(data){
                     $.each(data, function(key, val){ 
                     // for populatingform
                          $('#usernameField').attr('value', val.username);
                           $('#passwordField').attr('value', val.password);
                         });
                     });

 $(document).ready(function() {
          //form processing goes here and works ok
             getAccount(); 
      });

      </script>

<form id="callAccForm" enctype='multipart/form-data'>
<input type="text" name="username" id="usernameField" value="" placeholder="Username"/>
<input type="password" name="newpassword" value="" placeholder="New Password"/>
<a href"#" button id="updateAcc"  data-role="button">Save</a>
</form>

$(文档).ready(函数(){
$('#updateac')。点击(函数(){
var formData=$(“#callUpdateForm”).serialize();
$.ajax({
类型:“POST”,
url:“/process/update account.php”,
cache:false,
数据类型:'json',//json响应
数据:formData,
成功:功能(res){
如果(关于成功){
$(“#notify.success”).show();//显示成功消息
$(“#notify.success”).delay(2000).hide(“slow”);//淡出
setTimeout(函数(){
$.mobile.changePage('account.html',{reloadPage:true,transition:“fade”});//重定向到配置文件
}, 2000);
}否则{
//显示错误消息
$(“#notify.error”).show();//显示错误消息
$(“#notify.error”).delay(2000.hide(“slow”);//淡出
}
},
错误:函数(){
警报(“不工作”);
}
});
返回false;
});
});
函数getAccount(){
$.getJSON(“/json/account.json.php”,{id:localStorage.getItem(“id”)},函数(数据){
$.each(数据、函数(键、val){
//用于填充形式
$('#usernameField').attr('value',val.username);
$('#passwordField').attr('value',val.password);
});
});
$(文档).ready(函数(){
//表单处理在这里运行正常
getAccount();
});
关键问题是,在从登录页面重定向后,当数据正确填充时,“更新”按钮不起作用,除了和任何其他带有onclick事件的按钮外。但是,如果我直接单击update-account.html,它们确实起作用


这是否与我在重定向后加载页面的方式有关?我是否无法正确加载内容?这就像需要重新加载页面才能正常工作一样。

您可以检查这一点,它将为您的应用程序jqm+主干提供一个webskeleton,所有动画中的问题和您的问题都在那里得到解决。also对于jqm来说,让你的应用程序在phonegap上轻量级是最好的框架

你在哪个文件中给出了onclik事件,以及你是如何加载它们的?在同一页面中,我有按钮在单击事件中调用的功能。我重新编辑了上面的代码