Skip to content

Instantly share code, notes, and snippets.

View landonsanders's full-sized avatar

Landon Sanders landonsanders

View GitHub Profile
// model
function Model () {
this._state = {}
return this
}
Model.prototype.get = function (key) {
return this._state[key]
}
// Set up a simple object to use as "context"
var context = { foo: "bar" };
// A function that uses a reference to a variable called "foo"
// on the "this" context.
function returnFoo () {
return this.foo;
}
// This variable does not exist on scope, so is undefined.
@charitygrace
charitygrace / external-links.js
Created November 13, 2013 16:27
Generic code to open all external links in a new tab/window #webvanta
@mikekwright
mikekwright / getTodos.js
Created February 13, 2013 21:46
Dynamic list creation from json results (using only domcore js) for ASP.NET MVC Tutorial 4.
function getTodos(callback) {
var request = new XMLHttpRequest();
request.open("Get", "/api/Todo", true);
request.onload = function() {
console.log("Returned");
if (request.error) {
console.log(request.error);
} else {
var response = JSON.parse(request.responseText);
console.log(response);
@darrenderidder
darrenderidder / mvc-example1-1.js
Created August 11, 2012 16:25
simple mvc example
var Model = {};
var View = {};
var Controller = {};