-4
我想用「userPw」值替換「showPw」跨度 - 我試圖使用profilePassword來執行此操作,當它們選擇更改密碼時設置它。用JQuery中的一個變量替換跨度
如果頁面發現一個以前沒有設置,那麼就應該把defaultPassword這是0000
目前,它只能顯示999價值,它不會更新。雖然我已經測試過「userPw」的值,並且它在警報,默認密碼等等中正確顯示......任何想法?
這裏是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
我建立一個應用程序與科爾多瓦
請顯示重現此問題所需的完整代碼。 –
是更改密碼對象的一部分? –
我已經添加了www文件來下載,希望這會有所幫助 –