Skip to content

Instantly share code, notes, and snippets.

@Andrew-Max
Created August 6, 2014 19:29
Show Gist options
  • Save Andrew-Max/c11fbb4b5c7bfe4ce2af to your computer and use it in GitHub Desktop.
Save Andrew-Max/c11fbb4b5c7bfe4ce2af to your computer and use it in GitHub Desktop.
/* Put your CSS here */
html, body {
margin: 20px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/2.1.0/normalize.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"></script>
<script src="http://builds.emberjs.com/tags/v1.6.1/ember.js"></script>
<script src="http://builds.emberjs.com/beta/ember-data.js"></script>
</head>
<body>
<script type="text/x-handlebars">
<h2>Welcome to Ember.js</h2>
<ul>
<li>{{#link-to 'index'}}Link to Index route{{/link-to}}</li>
<ul>
<br>
<br>
{{input value=foo}}
<button type='submit' {{action 'xxx' foo}}>Submit</button>
<div>
{{foo}}
</div>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="index">
<p>Now you're on the index route</p>
{{#each}}
<div>
{{name}}
</div>
{{/each}}
</script>
</body>
</html>
App = Ember.Application.create();
App.Router.map(function() {
this.route('foo');
});
App.ApplicationAdapter = DS.FixtureAdapter;
App.Foos = DS.Model.extend({
name: DS.attr()
});
App.Foos.FIXTURES = [
{
id: 1,
name: "alpha"
},
{
id: 2,
name: "gamma"
}
];
App.IndexRoute = Ember.Route.extend({
model: function() {
return this.store.find('foos');
}
});
App.ApplicationController = Ember.ArrayController.extend({
actions: {
xxx: function (params) {
this.store.createRecord('foos', {
name: params
});
}
}
});
App.IndexController = Ember.ArrayController.extend({
actions: {
xxx: function (params) {
console.log(params);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment