amandragon / todo_spa

a todo app to demonstrate spas and ajax

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SPA App

Lesson Discussion

A Note This

AFTER

var App = {
  msg:"hello world!", 
  logMsg: function(){
    console.log(this);
    console.log(this.msg)
  }, 
  Views: {
    msg: "Best App, sorta", 
    logMsg: App.logMsg
  }
};


App.Views.logMsg()

BEFORE

var App = {}

App.msg = "Hello, World!";

App.logMsg = function(){ console.log(this); console.log(this.msg) } App.Views = {msg: "Best App, sorta"};

App.Views.logMsg = App.logMsg;

App.Views.logMsg()

SPA APP

First,

rails g controller todos index --no-test-framework

We neeed to work with the todo.js and the todos/index.html.erb

todos/index.html.erb

<div id="testCon">
</div>

All template information: ./templates/test.hbs

{{ msg }}

All application logic: /todos.js

$(function(){
    var testObj = {msg: "Hello, world!"};
    var $myTest = $(HandlebarsTemplates.test(testObj));
    
      $("#testCon").append($myTest);
});

About

a todo app to demonstrate spas and ajax


Languages

Language:Ruby 76.7%Language:JavaScript 20.0%Language:CSS 3.3%