Skip to content

Instantly share code, notes, and snippets.

@jamesgary
Created November 13, 2013 04:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesgary/7443833 to your computer and use it in GitHub Desktop.
Save jamesgary/7443833 to your computer and use it in GitHub Desktop.
App = Ember.Application.create();
App.IndexRoute = Ember.Route.extend({
model: function() {
return EmberFire.Array.create({
ref: new Firebase("https://dp-ember-chat.firebaseio.com/")
});
}
});
App.IndexController = Ember.ArrayController.extend({
msg: "",
from: "Guest" + Math.floor(Math.random() * 100),
actions: {
sendMessage: function() {
var msgRef = this.pushObject({
from: this.get("from"),
msg: this.get("msg"),
});
this.set("msg", null);
},
}
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<script type="text/x-handlebars" data-template-name="index">
{{#each controller}}
<div><em>{{from}}</em>: {{msg}}</div>
{{/each}}
<form {{action "sendMessage" on="submit"}}>
{{input id="nameInput" value=from placeholder="Name"}}
{{input id="messageInput" value=msg placeholder="Message..."}}
<button type="submit">Send</button>
<button {{action "destroyAll"}}>DESTROY EVERYTHING</button>
</form>
</script>
<script src="js/libs/jquery-1.9.1.js"></script>
<script src="js/libs/handlebars-1.0.0.js"></script>
<script src="js/libs/ember-1.1.2.js"></script>
<script src="https://cdn.firebase.com/v0/firebase.js"></script>
<script src="http://firebase.github.io/emberFire/emberfire-latest.js"></script>
<script src="js/app.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment