2016-12-26 992 views
-4

"showPw"スパンを "userPw"の値に置き換えたいのですが、パスワードを変更する際に設定されたprofilePasswordを使ってこれをしようとしています。JQueryの変数にスパンを置き換えてください

ページは1が以前に設定されていないことを発見した場合、それは現在0000

あるDefaultPassword値を持参してくださいが、それだけで999値を示し、それは更新されません。私は "userPw"の値をテストしましたが、それはアラートで正しく表示されますが、それとdefaultPasswordなど...どんなアイデアですか?ここで

のJavascriptです:

changePassword: function(page){ 
     var profilePassword = window.localStorage.getItem("userPw"); 
     var defaultPassword = "0000"; 
     if(!profilePassword){ 
      window.localStorage.setItem("userPw", defaultPassword); 
      $('.appProfile').find('span.showPw').text(defaultPassword); 
      //document.getElementById('').value = defaultPassword ; 
     } 
     else{ 
      //alert(profilePassword +'--') 
      //document.getElementById('showPw').value = profilePassword ; 
      $('#showPw').val(profilePassword) 
     }; 

    page.querySelector('[component="button/updatePassword"]').onclick = function() { 
      var newPassword = $('#setPw').val()//document.getElementById('setPw').value; 
      window.localStorage.setItem("userPw", newPassword); 
      //document.getElementById('showPw').value = newPassword ; 
      $('.appProfile').find('span.showPw').text(profilePassword); 

alert(newPassword) 

$(profilePassword).val(newPassword) 

      navigator.notification.alert(
       'PIN changed Successfully', // message 
       null, // callback 
       'Phindor', // title 
       'Ok'     // buttonName 
      ); 
     // window.localStorage.setItem("userPwOK", result.success); 
     // console.log(result.message); 
     // location.reload(true); 
    }; 

    page.querySelector('[component="button/profilePage"]').onclick = function() { 

     myApp.currentPage.myNavigator.popPage(); 
    }; 
} 

ここでHTMLれる:

<ons-template id="changePassword.html"> 
      <ons-page id="changePassword"> 
       <div class="appProfile"> 
        <br> 
        <br> 
        <br> 
        <br> 
        <br> 
        <br> 
        <br> 
        <br> 
        <div style="text-align: center"> 
         <b>Your current password: </b> 
        <br> 
        <br> 
        <span id="showPw">999</span> 
        <br> 
        <br> 
        <br /> 
         <b>Please select your new password:</b></span> 
        <br> 
        <br> 
        <ons-input type='text' id="setPw" name="setPw" placeholder="Type your new password here"></ons-input> 
        <br /> 
        <br /> 
        <br /> 
        <ons-button component="button/updatePassword" ripple>Update Password</ons-button> 
        <br /> 
        <br /> 
        <br /> 
        <ons-button component="button/profilePage" ripple>Back</ons-button> 

        </div> 


       </div> 
      </ons-page> 
    </ons-template> 

全体wwwディレクトリはここにある:https://wetransfer.com/downloads/76bc6b9f75a44b7f7054036a7cf478ab20161226102828/3be6ca

私はコルドバ

でアプリケーションを構築しています
+0

この問題を再現するために必要な完全なコードを示してください。 –

+0

はオブジェクトのパスワードの一部を変更しますか? –

+0

私はダウンロードするためにwwwファイルを追加しました。うまくいけば助けてくれるでしょう –

答えて

0

さて、多くの試行錯誤の後、私は彼の下で彼を使用して仕事を得た頌歌:

changePassword: function(page){ 
      var profilePassword = window.localStorage.getItem("userPw"); 
      var defaultPassword = "0000"; 
      if(!profilePassword){ 
       $('#showPw').text(defaultPassword); 
       //document.getElementById('').value = defaultPassword ; 
      } 
      else{ 
       //alert(profilePassword +'--') 
       //document.getElementById('showPw').value = profilePassword ; 
       $('#showPw').text(profilePassword); 
      }; 

     page.querySelector('[component="button/updatePassword"]').onclick = function() { 
       var newPassword = $('#setPw').val()//document.getElementById('setPw').value; 
       window.localStorage.setItem("userPw", newPassword); 
       document.getElementById('showPw').value = newPassword ; 
       $('#showPw').text(newPassword); 

    alert(newPassword) 

    $(profilePassword).text(newPassword) 

       navigator.notification.alert(
        'PIN changed Successfully', // message 
        null, // callback 
        'Phindor', // title 
        'Ok'     // buttonName 
       ); 
      // window.localStorage.setItem("userPwOK", result.success); 
      // console.log(result.message); 
      // location.reload(true); 
     }; 

     page.querySelector('[component="button/profilePage"]').onclick = function() { 

      myApp.currentPage.myNavigator.popPage(); 
     }; 
    }, 

主な問題は、.valはこれで過ごした誰の時間のような場所 "$(profilePassword)は.text(NEWPASSWORD)"

おかげで.TEXTされている必要がありました!これが少なくとも同じ問題を抱えている人には便利だと思います。

関連する問題