Blame view

client/templates/public/signup.js 1.45 KB
3b214be5e   Ryan Glover   Convert all Coffe...
1
2
3
4
5
6
7
8
  /*
  * Controller: Signup
  * Template: /client/views/public/signup.html
  */
  
  /*
  * Created
  */
76b8987a6   Ryan Glover   Update created an...
9
  Template.signup.onCreated(function(){
3b214be5e   Ryan Glover   Convert all Coffe...
10
    // Code to run when template is created goes here.
76b8987a6   Ryan Glover   Update created an...
11
  });
3b214be5e   Ryan Glover   Convert all Coffe...
12
13
14
15
  
  /*
  * Rendered
  */
76b8987a6   Ryan Glover   Update created an...
16
  Template.signup.onRendered(function(){
3b214be5e   Ryan Glover   Convert all Coffe...
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
    $('#application-signup').validate({
      rules: {
        emailAddress: {
          required: true,
          email: true
        },
        password: {
          required: true,
          minlength: 6
        }
      },
      messages: {
        emailAddress: {
          required: "Please enter your email address to sign up.",
          email: "Please enter a valid email address."
        },
        password: {
          required: "Please enter a password to sign up.",
          minlength: "Please use at least six characters."
        }
      },
      submitHandler: function(){
        // Grab the user's details.
        user = {
          email: $('[name="emailAddress"]').val(),
          password: $('[name="password"]').val()
        }
  
        // Create the user's account.
        Accounts.createUser({email: user.email, password: user.password}, function(error){
          if(error){
c8b07469e   Ryan Glover   Add themeteorchef...
48
49
50
            Bert.alert(error.reason, 'danger');
          } else {
            Bert.alert('Welcome!', 'success');
3b214be5e   Ryan Glover   Convert all Coffe...
51
52
53
54
          }
        });
      }
    });
76b8987a6   Ryan Glover   Update created an...
55
  });
3b214be5e   Ryan Glover   Convert all Coffe...
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
  
  /*
  * Helpers
  */
  
  Template.signup.helpers({
    example: function(){
      // Code to run for helper function.
    }
  });
  
  /*
  * Events
  */
  
  Template.signup.events({
    'submit form': function(e){
      // Prevent form from submitting.
      e.preventDefault();
    }
  });