简体   繁体   English

Parse.com-无法向用户添加其他字段

[英]Parse.com - Cannot add additional fields to User

Just getting started with Parse.com and following their JavaScript ToDo app tutorial and having some issues. 刚开始使用Parse.com并遵循他们的JavaScript ToDo应用程序教程并遇到一些问题。

Basically it will work perfectly and post to the Parse database when I just have the Username and Password but if I try to add any additional fields like email or phone, it won't send it to the database. 基本上,它可以完美运行并在我只有用户名和密码时发布到Parse数据库中,但是如果我尝试添加任何其他字段(如电子邮件或电话),它将不会将其发送到数据库中。 I have already defined both email and phone fields in my Parse database. 我已经在我的Parse数据库中定义了电子邮件和电话字段。

Any help would be appreciated. 任何帮助,将不胜感激。 Thanks! 谢谢!

My html for my form: 我的HTML为我的形式:

<script type="text/template" id="login-template">
  <header id="header"></header>
   <form class="signup-form">
      <h2>Sign Up</h2>
      <div class="error" style="display:none"></div>
      <input type="text" id="signup-username" placeholder="Username" />
      <input type="password" id="signup-password" placeholder="Create a Password" />
      <input type="email" id="signup-email" placeholder="Email" />
       <input type="text" id="signup-phone" placeholder="Phone" />
      <button>Sign Up</button>
    </form>
  </div>
</script>

My JS: 我的JS:

var LogInView = Parse.View.extend({
events: {
  "submit form.signup-form": "signUp"
},

el: ".content",

initialize: function() {
  _.bindAll(this, "signUp");
  this.render();
},

signUp: function(e) {
  var self = this;
  var username = this.$("#signup-username").val();
  var password = this.$("#signup-password").val();
  var email = this.$("#signup-email").val();
  var phone = this.$("#signup-phone").val();

  Parse.User.signUp(username, password, email, phone, { ACL: new Parse.ACL() }, {
    success: function(user) {
      new ManageTodosView();
      self.undelegateEvents();
      delete self;
    },

    error: function(user, error) {
      self.$(".signup-form .error").html(error.message).show();
      self.$(".signup-form button").removeAttr("disabled");
    }
  });

  this.$(".signup-form button").attr("disabled", "disabled");

  return false;
},

render: function() {
  this.$el.html(_.template($("#login-template").html()));
  this.delegateEvents();
}
});

You should use the following syntax, like specified in the javascript docs ( https://parse.com/docs/js_guide ): 您应该使用以下语法,例如javascript docs( https://parse.com/docs/js_guide )中指定的语法:

var user = new Parse.User();
user.set("username",username);
user.set("password",password);
user.set("email",email);
user.set("phone",phone);

user.signUp(null,{
    success:function(user){...},
    error:function(user,error){...}
});

You can add any fields you want with the set method. 您可以使用set方法添加所需的任何字段。

I had to change <!--<button>Submit</button>--> to <!--<input type="submit"></input>--> to get this to work but then it did. 我必须将<!--<button>Submit</button>--> to <!--<input type="submit"></input>-->才能使它正常工作,但后来做到了。 Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM