Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
<html>
<head>
<title>ToDo List</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style></style>
<title>CouchDB jQuery Examples</title>
<script src="script/jquery.js"></script>
<script src="script/handlebars.js"></script>
<script src="script/ember.js"></script>
<script src="script/ember-data.js"></script>
<script src="script/couchdb_adapter.js"></script>
<script type="text/javascript">
App = Ember.Application.create();
App.store = DS.Store.create({
adapter: DS.CouchDBAdapter.create({
db: 'testdb',
designDoc: 'todo'
}),
revision: 11
});
ToDo = DS.Model.extend({
type: DS.attr('string'),
title: DS.attr('string'),
content: DS.attr('string'),
creator: DS.attr('string'),
created_at: DS.attr('string'),
done: DS.attr('string'),
}),
App.todo = App.store.find(ToDo, '72674863c864a2dde83ffa535a007e4c')
// Document is found and title is shown in tenplate (App.todo.title)
App.todo = App.store.createRecord(ToDo, {
type: 'ToDo',
title: 'New ToDo',
content: 'Some Details',
creator: 'Me',
created_at: '2013-01-05',
done: 'false'
});
App.store.commit();
// Document is stored as expected
App.todos = App.store.findQuery(ToDo, {
type: 'view',
viewName: 'todos',
options: {
include_docs: true
}
});
App.ApplicationView = Ember.View.extend({
templateName: 'application'
});
</script>
</head>
<body>
<script type="text/x-handlebars" data-template-name="application">
<h1>Data</h1>
{{App.todo.title}}
{{#each App.todos}}
{{title}}
{{/each}}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.