Skip to content

Commit

Permalink
Add ember.js, todoItem model. Add template-name to index. Load ember.…
Browse files Browse the repository at this point in the history
…js lib in main. Create ember app in app.js.
  • Loading branch information
abram777 committed Dec 16, 2012
1 parent c2c2e84 commit 9803bf9
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</head>
<body>
<div class="container">
<script id="todo-list-container" type="text/x-handlebars-template">
<script id="todo-list-container" type="text/x-handlebars-template" data-template-name="application">
<div class="todo-list-container">
<div><h2>{{title}}</h2></div>
<ul>
Expand Down
4 changes: 3 additions & 1 deletion js/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_4bram = {};
//_4bram.App = Ember.Application.create();
_4bram.ToDoList = [
'Load requirejs', 'Load underscorejs', 'Apply styling with Sass',
'Generate View with Handlebars', 'Implement Ember'
Expand All @@ -7,4 +8,5 @@ _4bram.ToDoList = [
_4bram.Render = function (sourceId, context) {
var template = Handlebars.compile($(sourceId).html());
return template(context);
};
};

19 changes: 19 additions & 0 deletions js/ember-1.0.0-pre.2.min.js

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
require(['jquery', 'handlebars', 'underscorejs-min', 'app'], function ($) {
require(['jquery', 'underscorejs-min', 'handlebars', 'ember-1.0.0-pre.2.min', 'app'], function ($) {
$(function () {
console.info('jQuery loaded!', $);
console.info('Handlebars loaded!', Handlebars);
console.info('_ loaded!', _);
console.info('Handlebars loaded!', Handlebars);
console.info('Ember loaded!', Ember);
console.info('App loaded!', _4bram);

var todoList = {};
Expand All @@ -13,6 +14,13 @@ require(['jquery', 'handlebars', 'underscorejs-min', 'app'], function ($) {
todoList.todoItems.push({todoText: listItem})
});

// var view = Ember.View.create({
// templateName: 'application',
// title: 'ToDo List',
// todoItems: todoList.todoItems
// }).append('#todo-list-container');

// _4bram.App.initialize();
$('.container').html(_4bram.Render('#todo-list-container', todoList));
});
});
4 changes: 4 additions & 0 deletions js/models/todoItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TodoItem = Ember.Object.extend({
title: '',
belongsTo: 1
});

0 comments on commit 9803bf9

Please sign in to comment.