1
基本上,我使用Jquery驗證包作爲在Meteor創建和註冊帳戶時向用戶發送錯誤的方式,因爲樣板界面在我的情況下不起作用。創建Meteor帳戶時沒有響應Jquery驗證
無論如何,當用戶嘗試註冊一個帳戶時,我在客戶端根本得不到迴應。用戶只是在沒有消息或重定向的情況下創建的,就像它應該具有的一樣。
下面是特定的代碼:
Template.createAccount.onRendered(function(){
var validator = $('.register').validate({
submitHandler: function(){
user = {
email: document.getElementById("email").value,
password: document.getElementById("password").value
};
Accounts.createUser({
email: user.email,
password: user.password,
function(error){
if(error){
if(error.reason == "Email already exists."){
validator.showErrors({
email: "The email belongs to a registered user."
});
}
} else{
console.log("Account successfully created.");
Router.go("starter");
}
}
});
}
});
})
我使用用於與被(爲登錄用於帳戶創建Meteor.loginWithPassword()
和Accounts.createUser()
)不同的流星帳戶功能,唯一的例外帳戶登錄相同的代碼的邏輯。
根本沒有響應,所以它可能必須對回調函數做些什麼,因爲用戶帳戶是創建的,但客戶端上沒有顯示任何消息。