Ember Data Mockjax
by Ashokaditya Mohanty
HTML
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.5.2/jquery.mockjax.js"></script>
<script src="http://ember.alexspeller.com/handlebars-1.0.0.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script src="http://ember.alexspeller.com/canary/shas/5c30be4fe354b57a9241be6cd14f0b3fae977c0e/ember.js"></script>
<script src="http://ember.alexspeller.com/canary/shas/45d196b2907ae0ddca2ffc2b50ce84fbc0e275c6/ember-data.js"></script>
<script type="text/x-handlebars">
<div class="container">
<form {{action "updateUser" on="submit"}}>
<h2>Create User</h2>
<div class="form-group">
<label for='name'>Name</label>
{{input value=name id='name' class="form-control"}}
</div>
<div class="form-group">
<label for='email'>Email</label>
{{input value=email id='email' class="form-control"}}
</div>
<div class="form-group">
<label for='password'>Password</label>
{{input type="password" value=password id='password' class="form-control"}}
</div>
<div class="form-group">
<label for='password-confirmation'>Password confirmation</label>
{{input type="password" value=passwordConfirmation id='password-confirmation' class="form-control"}}
</div>
<button class="btn btn-primary btn-block" type="submit">Save</button>
</form>
</div>
</script>
CoffeeScript
window.App = Em.Application.create()
App.ApplicationAdapter = DS.ActiveModelAdapter.extend()
App.ApplicationRoute = Em.Route.extend
model: ->
@store.createRecord 'user'
actions:
updateUser: ->
alert "Updating user #{@currentModel.get 'name'}"
App.User = DS.Model.extend
name: DS.attr 'string'
email: DS.attr 'string'
password: DS.attr 'string'
passwordConfirmation: DS.attr 'string'