Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script>
<script src="http://builds.emberjs.com/ember-latest.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <script type="text/x-handlebars" data-template-name="index">
    <h1>Create New User</h1>
    {{user-form submit="createUser" cancel="cancelUserCreation" submitTitle="Create User"}}
  </script>
  
  <script type="text/x-handlebars" data-template-name="components/user-form">
   <form {{action "submit" on="submit"}}>
     <p><label>Name {{input type="text" value=name}}</label></p>
     <p><label>Bio {{textarea value=bio}}</label></p>
     
     <button {{action "cancel"}}>Cancel</button>
     <input type="submit" {{bindAttr value=submitTitle}}>
   </form>
  </script>
</body>
</html>
 
App = Ember.Application.create();
App.IndexController = Ember.ObjectController.extend({
  actions: {
    createUser: function(user) {
      alert("Created user " + user.name + " with bio " + user.bio + "."); 
    },
    
    cancelUserCreation: function() {
      alert("Canceled user creation.");
    }
  }
});
App.UserFormComponent = Ember.Component.extend({
  actions: {
    submit: function() {
      this.sendAction('submit', {
        name: this.get('name'),
        bio: this.get('bio')
      });
    },
    
    cancel: function() {
      this.sendAction('cancel');
    }
  }
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x