2
以下是我的表單模板,它加載在我的register.html頁面的標題中,並顯示在div#register-tpl中。它顯示正常。用戶會被提示輸入用戶名,電子郵件和密碼進行註冊:使用Parse Javascript SDK註冊用戶
<script id="register-tpl" type="text/x-handlebars-template">
<form class="form-register" role="form">
<h1>Sign up!</h1>
<h2><span class="typcn typcn-user-add"></span> Create an account</h2>
<p><input type="text" id="username" name="username" class="form-control" placeholder="Username" required="" autofocus=""></p>
<p><input type="password" id="password" name="password" class="form-control" placeholder="Password" required=""></p>
<p><input type="text" id="email" name="email" class="form-control" placeholder="Email" required="" autofocus=""></p>
<p><button class="button" type="submit">Sign up</button></p>
<p>Already have an account? <a class="app-link" href="admin.html">Log in!</a></p>
</form>
</script>
下面是用於添加新用戶對數據庫的我的Javascript代碼:
var RegisterView = Parse.View.extend({
template: Handlebars.compile($('#register-tpl').html()),
events: {
'submit .form-register': 'register'
},
register: function(e) {
e.preventDefault();
var username = document.getElementById('username').value;
var password = document.getElementById('password').value;
var email = document.getElementById('input').value;
var user = new Parse.User();
user.set("username", username);
user.set("password", password);
user.set("email", email);
user.signUp(username, password, email, {
success: function(user) {
var welcomeView = new WelcomeView({ model: user });
welcomeView.render();
$('.register-container').html(welcomeView.el);
},
error: function(user, error) {
console.log(error);
}
});
},
render: function(){
this.$el.html(this.template());
}
});
沒有人有任何想法爲什麼這不提交所需的信息?它甚至不認可在我的Parse儀表板上創建新用戶。這裏有什麼根本性的缺陷嗎?謝謝,所有幫助非常感謝!