2014-01-30 39 views
0

我在我的phonegap應用程序中有一個奇怪的行爲,我似乎無法找到解決方案。mobile.changePage頁面不'active'後在phonegap JQM應用程序重定向

我的應用程序有一個登錄表單,在登錄成功後,重定向到更新帳戶頁面。

的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> 

,關鍵的問題是,經過從登錄頁面重定向,而數據正確填充,更新按鈕不起作用,以及任何其他帶有onclick事件的按鈕。但是,如果我直接點擊update-account.html,他們的確會工作。

這是我在重定向後如何加載頁面?我無法正確加載內容嗎?這就像它需要一個頁面重新加載才能正常工作。

+0

你給了onclik事件的文件以及你如何加載它們? –

+0

在同一頁面中,我具有按鈕在click事件上調用的功能。我上面重新編輯了我的代碼 – user3189734

回答

0

你可以檢查這個repo,它將爲你提供一個適用於你的應用程序的網絡骨架jqm +主幹,動畫中的所有問題以及你的問題都在那裏解決。它也是jqm的最佳骨架,使你的應用在電話號碼上加權爲

相關問題