Skip to content

Instantly share code, notes, and snippets.

@kaheglar
kaheglar / jquery-assert.js
Created June 23, 2011 12:38
jQuery assert - throw error msg if condition false
(function($) {
$.assert = function(condition, msg) {
if (!condition) {
$.error(msg);
}
};
})(jQuery);
@kaheglar
kaheglar / class.js
Created January 5, 2012 11:19
Simple JavaSctipt Inheritance Module - ASM Compliant
/**
* Class Module (No Dependencies)
*/
define(function() {
// Set to true when creating New Prototype to ensure "_constructor" is not executed
var extending = false;
// Base Constructor
var Class = function() {};
@kaheglar
kaheglar / index.html
Last active December 23, 2015 13:09
Backbone Nested Views with MutationObservers.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Self Initializing Backbone View</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="jquery.js"></script>
<script src="underscore.js"></script>
<script src="backbone.js"></script>
@kaheglar
kaheglar / render-ko.js
Created March 15, 2017 14:39
Knockout server-side rendering.
const domino = require('domino');
const html = `
<!DOCTYPE html>
<html>
<body>
<ul data-bind="foreach: list">
<li data-bind="text: $data"></>
</ul>
@kaheglar
kaheglar / app.js
Created June 23, 2017 07:30
Knockout server-side rendering - Making asynchronous components synchronous
const ko = require('knockout');
ko.components.register('the-beatles', {require: 'the-beatles'});