Skip to content

Instantly share code, notes, and snippets.

@jstrimpel
jstrimpel / gist:10047510
Created April 7, 2014 20:36
wrap library
define(['l!app/vendor/client/d3'], functtion () {
// library code
});
@jstrimpel
jstrimpel / gist:ce9e91952745834ab050
Last active August 29, 2015 14:05
lazo base controller and sessions model example
// base controller
define(['lazoCtl'], function (Ctl) {
'use strict';
return Ctl.extend({
index: function (options) {
this.loadModel('session', {
success: function (model) {
@jstrimpel
jstrimpel / gist:e48f42ab151e1511fded
Created August 28, 2014 23:38
lazo - set html and body tag class
define(['lazoApp'], function (App) {
'use strict;
return App.extend({
initialize: function (callback) {
var html = '<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]--><html lang="en">';
LAZO.app.setHtmlTag(html);
LAZO.app.setBodyClass('some-class another-class');
@jstrimpel
jstrimpel / gist:7aa111403f555986b7e9
Created September 19, 2014 00:03
socket.io and lazo model
// in a controller
// you can either update the collection directly or send
// a message in the LAZO.app dispatcher
// (you can use a controller dispatcher if you want to be more granular)
var socket = io();
var self = this;
var notifications = this.ctx.collections.notifications;
// three different approaches to re-rendering a badge count
socket.on('notification', function (msg) {
@jstrimpel
jstrimpel / gist:bca68962fab529851bb1
Created September 19, 2014 00:22
lazo model authentication fn
// backs user model
define(['lazoSyncher'], function (LazoSyncher) {
return LazoSyncher.extend({
authenticate: function (credentials, options) {
// authenticate user using credentials
// you can call options.success or options.error
// update the user model, auth token, etc.
}
@jstrimpel
jstrimpel / gist:e42a57475124105047df
Created September 22, 2014 17:41
lazo server utils and request node module
// https://www.npmjs.org/search?q=request
define(['request'], function (request) {
'use strict';
return {
image: function (req, options) {
// use request module here and forward the response to
// the appropriate options callback
@jstrimpel
jstrimpel / gist:1927b32d95fbf13d3a8f
Created September 23, 2014 23:24
lazo: passing models to child components
define(['lazoCtl'], function (LazoCtl) {
'use strict';
return LazoCtl.extend({
index: function (options) {
this.addChild('some-target', 'some-component', {
// pass all references or cherry pick the ones you want
ctx: {
@jstrimpel
jstrimpel / gist:b405db00ccffad3bc182
Created September 23, 2014 23:30
lazo: base controller that loads data last when executing an action
// application base controller that resides at app/ctl.js
define(['lazoCtl'], function (LazoCtl) {
'use strict';
return LazoCtl.extend({
index: function (options) {
var self = this;
@jstrimpel
jstrimpel / gist:968601bf5ffeb8835504
Created September 23, 2014 23:40
lazo: base controller that loads data before executing action
// application base controller that resides at app/ctl.js
define(['lazoCtl'], function (LazoCtl) {
'use strict';
return LazoCtl.extend({
models: ['defaultModel1', 'defaultModel2'],
loadModels: function (callback) {
@jstrimpel
jstrimpel / gist:eb4939f34853941f2329
Created October 10, 2014 21:29
requirejs error
{ [Error: Tried loading "continuation-local-storage" at /Users/jstrimp/github.com/jstrimpel/lazojs/continuation-local-storage.js then tried node's require("continuation-local-storage") and it failed with error: Error: Cannot find module 'continuation-local-storage']
originalError: { [Error: Cannot find module 'continuation-local-storage'] code: 'MODULE_NOT_FOUND' },
moduleName: 'continuation-local-storage',
requireModules: [ 'continuation-local-storage' ],
requireMap:
{ prefix: undefined,
name: 'continuation-local-storage',
parentMap:
{ prefix: undefined,
name: 'loggerUtils',